On my previous Gambas tutorial, I have shown how to retrieve value from a text box into a message box. On that tutorial, any user typed in the text box will be displayed on the message box. Now, we will learn something a little bit advanced on the text box. We will validate the text box value entered by user. For example, we will learn how to validate user input on the text box if it is number or not number.
IsNumber Function on Gambas
When user type any number, the message box will appear telling that user has entered number. But if its not number, a message box will also appear telling that user has entered a non number value. See how this program when running below.
Public Sub Button1_Click()
If IsNumber(TextBox1.Text) Then
Message("You entered Number")
Message("You entered non Number")
The key here is the use of IsNumber function. IsNumber will convert string to number safely. IsNumber function will return True if the string can be converted to Number. Otherwise, it will return False.