variable trouble

Johnson

Well-known member
Joined
Mar 6, 2009
Messages
158
Programming Experience
Beginner
Im trying to do a loop between to timers. Im a complete beginer so there is probably better ways to do this so feel free to tell me so.

when i click a button (text h is a hidden text box as i dont no how to use a the same varible twice so i store the number in a text box) laugh yes :(

VB.NET:
    Private Sub Timer2_Tick_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

Dim x, n

x = 1
n = txtN.text

if x < n then 
        Timer2.Enabled = False
        Timer3.Enabled = True
x = x +1
txtH.text = x

end sub


   Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Dim ID

        ID = txtID.Text

          'performs more code here
        Timer3.Enabled = False
        Timer2.Enabled = True


    End Sub

yes im useless at vb :( i have to use timers so can any one help me here?
 
Well, I'm sure we could help you better if we knew why you need the timers, and knew what they do? You can set variables as Const if they don't change - set them in the as a class declaration not in any sub routine code block, then you do not need to use a hidden control - which is ineffient UI element usage. Also I know VB will let you declare your variable like - Dim Id, but it is better to declare them - Dim Id As String - Example:

VB.NET:
Public Class MyClass
  Const Id As String = <myStringConst>
 Private Sub DoSomething()
  textbox1.Text = Id
 End Sub
End Class
 
Back
Top