Results 1 to 3 of 3

Thread: reseting

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    12

    reseting

    I have a value in th picbox and it is a counter adding one each click how do i make it if it add one each time>





    VB Code:
    1. Dim num As Integer
    2.  
    3. Private Sub cmdclick_Click()
    4. picscore.Cls
    5. NumberCount = 1
    6.  
    7. End Sub
    8.  
    9. Private Sub cmdclick_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10. num = num + 1
    11.  
    12. picscore.Print num
    13. End Sub

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: reseting

    VB Code:
    1. Dim num As Integer
    2.  
    3. Private Sub cmdclick_Click()
    4. picscore.Cls
    5. [b]NumberCount = 1[/b]
    6.  
    7. End Sub
    8.  
    9. Private Sub cmdclick_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10. num = num + 1
    11.  
    12. picscore.Print num
    13. End Sub

    remove the line in bold.

    Plus, you have two subs that activate at the exact same time... Click and MouseDown events on a Command Box accomplish the same thing.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: reseting

    you need to declare num as a static, then it remembers the last value when the sub is run again

    VB Code:
    1. Static num as Long
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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