Results 1 to 4 of 4

Thread: counter

  1. #1

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    counter

    hi
    number1 for the first click
    number 2 for the second click
    number3 for the third click
    number 4 for the forth click
    and so on..
    thanks

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    VB Code:
    1. dim counter as long
    2.  
    3. public sub command1_click()
    4.  
    5. counter = counter + 1
    6.  
    7. msgbox counter
    8.  
    9. end sub


  3. #3
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    If you want to use this counter only inside your click sub this is better:
    VB Code:
    1. Public Sub Command1_Click()
    2.     Static Counter As Long
    3.  
    4.     Counter = Counter + 1
    5.     MsgBox Counter
    6. End Sub
    Learn, this is the Keyword...

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Here is a simple (short) way to increment a CommandButtons caption:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Command1.Caption = CStr(CInt(Command1.Caption) + 1)
    3. End Sub


    Note: Set the Caption to '0' (at load or at design time)




    Bruce.

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