String conversion to integers

I am beginning to develop an application for Desktop. The user has to enter an integer, then return, then an integer, then return, etc. Up to 32 integers. By the way, the input is a string. I don’t know how to convert the string to a set of integers: X1, X2, X3, … etc.

// s contains a set of integers

s = s.ReplaceLineEndings( &uA ) // linefeed
var arr() as string = s.Split( &uA ) // get each value as string

var nums() as integer
for each line as string in arr
  nums.AddRow line.Trim.ToInteger

// nums has your integers

(Untested code, allow for bugs)

For a simple TextField, you can get the integer/double value with the val() method:

result = val(textfield1.text)

If you are trying to use a TextArea and collect and integer you need to split the TextArea.text into an array as the quick-typing Kem mentions above.

Edit: I’m using 19r1.1, not the newer ones.

but careful with decimal places (comma or dot) if someone do copy/paste.

see Integer.FromString because Locale

You can use

Var myInt As Integer = Integer.Parse(myString)
// OR 
If IsNumeric(mytextfield.value) then 
// the textfield value can be parsed

Var myInt As Integer = Integer.Parse(myString)

End If

This is pretty safe, i do recommend you set a textfield mask so you’r sure it’s a numeric value.

Listbox input