Question constant cycling function.

Vega425

New member
Joined
Jul 8, 2008
Messages
2
Programming Experience
5-10
Can someone give me a quick example code to make code cycle? I basically want to have something happen one second after a user stops typing in a text box. (VB.NET 3.5 2008 express edition)

// ------------------------- Actionscript equivalent
VB.NET:
TIME = 1000;
onEnterFrame = function() {
      TIME--;
      if(TIME < 0) {
           runMyFunction();
           endThisCycling();
      }
}
 
Hello,

Probably, textchanged event can be used for your requirement. for example:

VB.NET:
 Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        If TextBox1.Text = "" Then
            Me.Timer1.Enabled = False
        Else
            Me.Timer1.Enabled = True
        End If

    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Me.Timer1.Enabled = False
        MsgBox(TextBox1.Text)

    End Sub

Drop a Textbox and a Timer control on a form and they try the above code.

Once you stop typing or make some change in the TextBox, it will show up
a message box.

Hope this helps.

Regards,

Allen
 
possibly do this (psuedocode)

VB.NET:
Private Sub TextBox1_TextChanged (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Me.Timer1.Stop()
Me.Timer1.Start()
End Sub

Sub Timer1_Tick (ByVal blah blah blah) Handles Timer1.Tick
MsgBox("Time's Up!")
End Sub
And then just set the tick property to one second and you're golden
 
Back
Top