-
it doesn't add up!
This is really wierd, and probably simple, but I can't get my counter to add more than once. It's simple code
Private Sub Form_Load()
Dim countnum As Integer
countnum = 0
End Sub
Private Sub cmdadd1_Click()
countnum = countnum + 1
lblcount.Caption = countnum
End Sub
my form is simply a command button (cmdadd1) and a label (lblcount). It works once, when I click on cmdadd1, but only once, regardless of how many times I click after that.
I'll feel stupid when you tell me whats wrong, but I already feel stupid for not being able to figure it out on my own.
-
Re: it doesn't add up!
Your code should give an error in the mdadd1_Click sub because countnum was not defined. Any way to make your code work remove the lineDim countnum as Integer
from the form_load sub and put it in the General Declarations.
-
Re: it doesn't add up!
In your example, there are two countnum variables... one local to FormLoad and one local to cmdAdd1_Click() try this instead...
option Explicit
Dim x as Integer
private Sub Command1_Click()
x = x + 1
Label1.Caption = x
End Sub
-
Re: it doesn't add up!
like I said, I feel stupid now :P Thanks for the help.