Converting text field string to integer

Hi. I have a text field in which users enter a value for the quantity they want something printed.
I need to convert TextField_qty.text to an integer so that I can act upon it properly in a printing loop.

What’s the simplest way to achieve this?

Thanks!

Hi Scott,

Try the “Val” method: Val — Xojo documentation

You can try:

Var myInteger as Integer = TextField_qty.text.ToInteger
1 Like

Maybe add in a check to make sure it is a number first

If TextField_qty.Text.IsNumeric Then
// your preferred conversion method
End If
2 Likes

Thanks folks!
TextField_qty.text.ToInteger is what I needed, and useful tip from Scott C.