|
-
Feb 22nd, 2002, 05:02 PM
#1
Thread Starter
Member
I knew it would happen...
You start programming in C++ for a couple of months and you forget how to do anything in VB. Can anyone help?
I am trying to use an array of buttons for a simple calculator demo. However, when I try to access the "click" procedure for each, it uses only one sub that is named
Private Sub Command1_Click(Index as Integer)
How do I make it so that when I click on Command1(3) it prints a 3.?
The button array thing is messing with my mind's concept of C++ arrays.
Thanks,
E.D.1870
"As for me, I am poor and needy but God is thinking about me right now." Psalm 40
-
Feb 22nd, 2002, 05:09 PM
#2
Fanatic Member
Here is a way, use the Index argument to take action depending on which button in the control array is clicked:
VB Code:
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
' Button 0 was cliked
' TODO: insert code for button 0
Case 1
' Button 1 was clicked
' TODO: insert code for button 1
Case 2
' Button 2 was clicked
' TODO: insert code for button 2
Case 3
' Button 3 was clicked
Debug.Print Index ' <<< act on button 3 in array
End Select
End Sub
It is worth pointing out that the Index argument indicates which button in the control array was clicked. If you want to find the index for a particular button on the screen, select it and look for the value of Index in the Properties window.
Hope this helps ya.
-
Feb 22nd, 2002, 05:11 PM
#3
Thread Starter
Member
Thanx alot. I felt really stupid asking such an easy question but I think it probably happens to everybody once in awhile.
Thanks,
E.D.1870
"As for me, I am poor and needy but God is thinking about me right now." Psalm 40
-
Feb 22nd, 2002, 05:12 PM
#4
Fanatic Member
Hell yeah :-) Happens often to me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|