Android Question extract single char from string

iz1kbp

Member
Hi to all...
In Visual basic 6 , to extract single chr from a string I use:
dim string as string
dim n as integer
string ="qwertyuio"
dim extrac as string
for n = 0 to (len(string)-1)
extract=mid(string,n,1)
next

in B4A....I'm not able to write a similar code, ghive me error!
I've searched some like this in forum but I've not found any.
Some one use CharAt ,other Chartostring...but no one works in B4A ambient
Is ther some one that can suggest me an example for android (B4A)?
thank's in advance
mario
 

hatzisn

Expert
Licensed User
Longtime User
@iz1kbp See this post:

 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User

B4X:
    Dim text As String = "qwertyuio"
    
    'extract one by one
    For i = 0 To text.Length - 1
        Dim character As String = text.CharAt(i)
        Log(character)
    Next
    
    'extract one by one
    Dim n As Int = 1
    For j = 0 To text.Length - 1
        Dim character As String = text.SubString2(j,n)
        Log(character)
        n = n + 1
    Next
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Please also note that DoEvents should be replaced by Sleep(0) in nowadays versions of Android. Also for InputList and InputDialog search for B4XDialog in the forum.
Also MsgBox with MsgBox2Async (see the example provided in the pop up window in B4A).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…