Use buttons to make a Textbox increase in number?

Ksmith1192

Member
Licensed User
Longtime User
Ok, so I am trying to make ButtonAscend make the number of Label 1 Increase by 1 every click, and ButtonDescend make the number of Label 1 Decrease by 1 every click. How would this be possible? Any questions please ask!

Thanks for the help! :sign0104:
 
Last edited:

lagore

Active Member
Licensed User
Longtime User
Have a global variable to hold the count then in the click event for each button increase or decrease the variable. You could have the same click event for the two buttons but set the tags for each button differently then use an if-else to check which button was pushed. Then update your label text.


Sent from my HTC One X using Tapatalk 2
 
Upvote 0

jgmdavies

Member
Licensed User
Longtime User
The following works here as expected.

HTH
Jim

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim Count As Int = 0

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim lblCount As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("Main")
   If FirstTime Then Count = 0

End Sub

Sub Activity_Resume

   UpdateUi

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnUp_Click

   Count = Count + 1
   UpdateUi

End Sub

Sub btnDown_Click

   Count = Count - 1
   UpdateUi

End Sub

Sub UpdateUi

   lblCount.Text = Count

End Sub
 
Upvote 0
Top