asp.net vb question ????????????

  • Thread starter Thread starter Jay W
  • Start date Start date
J

Jay W

Guest
when i type in the code below and press the Button 1 - 10 is written in my label. now when i press the button again it writes out 1 - 10 again.

For i As Integer = 1 To 10
lbl1.Text &= i.ToString() & "< br />"
Next

my question is when the button is pressed again why doesn't it realize it has already been pressed so it just has 1 - 10 written out once.
 
You should probably have a global variable that defines the state of the button:

Public alreadyPressed As Bool = False

and your code in the button would be:

If alreadyPressed = True Then Exit Sub 'check state of the button
For i As Integer = 1 To 10
lbl1.Text &= i.ToString() & "< br />"
Next
alreadyPressed = True 'If its the first time, make the value true
 
Back
Top