Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Gurus*
Posted
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...