|
-
Jun 10th, 2008, 01:03 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [2008] Adding The Number 1 Onto A Variable
I need to keep count of things in the app I'm working on. When the user clicks a button it adds 1 onto the variable "count".
Here's the code that doesn't work:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim count = 0
count = count + 1
Label1.Text = count.ToString()
End Sub
Ahhhhh! This is really bugging me! Please help! Any of it is greatly appreciated!
-
Jun 10th, 2008, 01:05 PM
#2
Addicted Member
Re: [2008] Adding The Number 1 Onto A Variable
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static count = 0
count += 1
Label1.Text = count.ToString()
End Sub
-
Jun 10th, 2008, 01:07 PM
#3
Thread Starter
Addicted Member
Re: [2008] Adding The Number 1 Onto A Variable
Wow! Thanks for the really quick reply - it's working now!
Thanks a lot!
-
Jun 10th, 2008, 01:08 PM
#4
Addicted Member
Re: [RESOLVED] [2008] Adding The Number 1 Onto A Variable
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Tag = (CInt(Button1.Tag) + 1).ToString
Label1.Text = count.ToString()
End Sub
-
Jun 10th, 2008, 01:13 PM
#5
Re: [2008] Adding The Number 1 Onto A Variable
 Originally Posted by Louix
Wow! Thanks for the really quick reply  - it's working now!
Thanks a lot!
That's great that it is working, but do you know & understand why it works? (or care to know?)
-tg
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
|