8 Years
Discussion Span
Last Post by Geek_Cyborg

In VB6.0, to easily create an array of command buttons, or any control for that matter, place a command button on the form, name it, and set whatever other properties you want. Then select the command button on the form in the design environment and just like you would copy and paste some text, press CTRL+C and CTRL+V. Answer yes to the msgbox and continue for as many buttons as you want.

Now, for accessing the code window, double click on one of the buttons and the code pane will come up and you should see something like...

Private Sub Command1_Click(Index As Integer)

End Sub

From there you could use either a select case statement to tell the difference between which button was pushed, like so...

Select Case Index
Case 0 'first button (could be move first if coding for recordset navigation)
Case 1 'second button (move previous (recordset naviation))
Case 2 '(Move next in reference to recordset navigation)
Case 3 '(Move last...)
End Select

Or you could use the if elseif structure...

If Index = 0 Then
ElseIf Index =1 Then

Good Luck

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.