B4R Question get character of string by index

Mostez

Well-Known Member
Licensed User
Longtime User
Hello,
How can I get single character of string by it's index i.e. vString as String = get("ABCD",2) returns 'C' not ascii value of 'C'

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim s() As Byte = "ABCD"
Dim b As Byte = s(2)
The value of b will be 67 which is the ascii code of 'C'. In most cases it is better to work with bytes and leave it as is.

You can convert it to string with:
B4X:
Dim bc As ByteConverter
Dim st As String = bc.StringFromBytes(Array As Byte(b))
 
Upvote 0

Similar Threads

Top