Results 1 to 4 of 4

Thread: I knew it would happen...

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    62

    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

  2. #2
    Fanatic Member HaxSoft's Avatar
    Join Date
    May 2000
    Location
    Ohio
    Posts
    593
    Here is a way, use the Index argument to take action depending on which button in the control array is clicked:

    VB Code:
    1. Private Sub Command1_Click(Index As Integer)
    2.  
    3.     Select Case Index
    4.         Case 0
    5.             '   Button 0 was cliked
    6.             '   TODO: insert code for button 0
    7.        
    8.         Case 1
    9.             '   Button 1 was clicked
    10.             '   TODO: insert code for button 1
    11.        
    12.         Case 2
    13.             '   Button 2 was clicked
    14.             '   TODO: insert code for button 2
    15.        
    16.         Case 3
    17.             '   Button 3 was clicked
    18.             Debug.Print Index   '   <<< act on button 3 in array
    19.     End Select
    20.    
    21. 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.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    62
    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

  4. #4
    Fanatic Member HaxSoft's Avatar
    Join Date
    May 2000
    Location
    Ohio
    Posts
    593
    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
  •  



Click Here to Expand Forum to Full Width