IsNumeric In iOS

I am creating an app in which the user has to enter an integer. If the user mistakenly enters Text, the app will crash.

Normally in Xojo, I use the code:

If not IsNumeric(txtNum.text) then AlertBox.Message = "This Is Not A Number" AlertBox.Title = "This Not A Number" AlertBox.Show Else //Do something else.

When I try to run the same code I get the error that IsNumeric does not exist. Is there an iOS equivalent?

I would use Integer.Parse http://developer.xojo.com/integer$Parse.

I tried this code hoping it would catch the exception and replace the text with 100, but when I add a string to txtNum it still crashes on the line:

value = Integer.FromText(txtNum.Text)

Dim value As Integer Try value = Integer.FromText(txtNum.Text) Catch e As BadDataException txtNum.Text="100" End Try

Crashing or stopping on an exception in the debugger ?
Big difference

Stopped on exception on line:

value = Integer.FromText(txtNum.Text)

Keep hitting step then
Stopping on an exception is NOT a crash

My mistake. I forgot that I had the project set to “Break On Exceptions.” Turned that off and everything works now.

Thanks for your help Norman. I appreciate it. :slight_smile:

And thank you Bob for pointing me in the right direction.

I rarely turn that off :stuck_out_tongue:

I don’t either, but that is why I forgot that the debugger would stop if it was on the Try and Catch