Android Question iterate a string

erovia

New Member
hi
how can i iterate a string?
this is what I've tried :
For i = 0 To inprogress.Text.Length - 1
A(i) = inprogress.Text(i)
Next

and also another question :
how can i convert strings to floats???
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
For i = 0 To s.Length - 1
   Dim c As String = s.CharAt(i)
Next

how can i convert strings to floats???
You don't need to do anything special:
B4X:
Dim f As Float = "12.34"
'or better
If IsNumber(inprogress.Text) Then
 f = inprogress.Text
Else
 Msgbox("Error", "")
End If
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
you can iterate a string like this:
B4X:
Dim s As String
Dim letter As String
For i = 0 To s.Length-1
    letter = s.SubString2(i,i+1)
Next

to convert a string to floats you can do it lile this:
B4X:
Dim s As String = "5.2"
Dim f As Double

If IsNumber(s) Then
    f = s
End If
 
Upvote 0
Top