roKeyboard input validation

Is there a way to check if the text entered in the box is numeric?

type(screen.GetText()) returns String
val(type(screen.GetText())) returns Float (even if the text is not numeric)

Thanks!

If you just want them to enter a number, you may want to try roPinEntryDialog.

You can’t see what you’re typing that way, but otherwise it works. In my case the number is a zip code, so having an incorrect zip code (can’t see what you’re typing) is probably still better than having an invalid zip code (code with letters in it). But if there is a way to make the PinEntryDialog show numbers as you type, that’d be helpful.

“peej” wrote:
Is there a way to check if the text entered in the box is numeric?

type(screen.GetText()) returns String
val(type(screen.GetText())) returns Float (even if the text is not numeric)

Thanks!

Here’s a somewhat clunky way to do it, but it works.

Function isInteger(MyText as String) as Boolean

if Len(MyText) = 0 return false

for i = 1 to Len(MyText)
digit = Mid(MyText, i, 1)
if Instr(1, “0123456789”, digit) = 0 return false
next

return true

End Function

if isInteger(ZipCode)
’ Do normal routine
else
’ Do error routine
endif

I like it. :laughing:

Thanks.