Number in textboxes

How do I get a number in a textbox to go up by one each time another textbox reaches 60



Answer this question

Number in textboxes

  • _Michael_

    Hi Ant_59,

    Using the textboxes txtBox1 and txtBox2 as an example, you could do something like the following:

    Private Sub txtBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtBox1.TextChanged

    If Val(Me.txtBox1.Text & "") >= 60 Then

    Me.txtBox2.Text = Val(Me.txtBox2.Text & "") + 1

    Me.txtBox1.Text = 0

    End If

    This uses the TextChanged event of txtBox1 to monitor the value, when it gets 60 (or above) it adds 1 to the value in txtBox2 and resets itself to 0.

    I have used the construct of Val(me.txtBox1.text &"") to deal with the case of txtBox1 (or txtBox2) being empty at which time it will return 0.

    I hope this helps.

    Regards

    Nigel


  • Number in textboxes