Gambas Tutorial – validate user input on a text box

October 13, 2016 | By | Reply More

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.

When user enter text to the textbox

When user entered text to the textbox

 

When user entered number to the textbox

When user entered number to the textbox

Code:

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.

Category: Ubuntu

Leave a Reply