[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!
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
Re: [2008] Adding The Number 1 Onto A Variable
Wow! Thanks for the really quick reply :) - it's working now!
Thanks a lot!
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
Re: [2008] Adding The Number 1 Onto A Variable
Quote:
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