Code question

fantasma62

Newcomer
Joined
Nov 23, 2002
Messages
18
Location
Miami, Florida
I have to labels and two buttons. What code can I use if I want a label to show a number and increase it in increments of one when I press a button? What code can I use to do the same with the other button so that in its corresponding label shows a number and increments it by one once you press the button? Also, as you increase the numbers in one, how can i decrease it on the other?

Thanks
 
Visual Basic:
Class yourClass

    Private iNumber1 As Integer = 10
    Private iNumber2 As Integer = 10

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        iNumber1 += 1
        iNumber2 -= 1
        Label1.Text = iNumber1.ToString()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        iNumber2 += 1
        iNumber1 -= 1
        Label2.Text = iNumber2.ToString()
    End Sub

End Class 'yourClass
 
Back
Top