S sarkis Member Licensed User Longtime User Mar 9, 2012 #1 Hi All, How to convert char to int ? and one more question why this get an error? Dim List1 as List Dim c as Char Dim i,j i=0 j=0 c=List1.Get(i).charAt(j) Thanks for answers Last edited: Mar 9, 2012
Hi All, How to convert char to int ? and one more question why this get an error? Dim List1 as List Dim c as Char Dim i,j i=0 j=0 c=List1.Get(i).charAt(j) Thanks for answers
joseluis Active Member Licensed User Longtime User Mar 9, 2012 #2 You know that i & j are strings, right? You must declare them like this if you want them to be Int: Dim i, j As Int Upvote 0
You know that i & j are strings, right? You must declare them like this if you want them to be Int: Dim i, j As Int
S sarkis Member Licensed User Longtime User Mar 9, 2012 #3 how to convert char to int ,char to byte so on ... I forget of course i and j are int and that doesn't work.' What about conversion? Upvote 0
how to convert char to int ,char to byte so on ... I forget of course i and j are int and that doesn't work.' What about conversion?
Ricky D Well-Known Member Licensed User Longtime User Mar 10, 2012 #4 if the c=List1.Get(i).charAt(j) is a number then just do something like B4X: Dim res As Int res = List1.Get(i).charAt(j) no special conversion needed or are you wanting the ascii number of the char? regards, Ricky Upvote 0
if the c=List1.Get(i).charAt(j) is a number then just do something like B4X: Dim res As Int res = List1.Get(i).charAt(j) no special conversion needed or are you wanting the ascii number of the char? regards, Ricky
S sarkis Member Licensed User Longtime User Mar 10, 2012 #5 convert Thanks for responding But Dim res As Int res = List1.Get(i).charAt(j) doesn't compile. It says unknown charat. I did folowing Dim str1 As String str1=List1.Get(i) res= Asc(str1.CharAt(j))-48 if you fnow shorter solusion please let me know. Upvote 0
convert Thanks for responding But Dim res As Int res = List1.Get(i).charAt(j) doesn't compile. It says unknown charat. I did folowing Dim str1 As String str1=List1.Get(i) res= Asc(str1.CharAt(j))-48 if you fnow shorter solusion please let me know.
specci48 Well-Known Member Licensed User Longtime User Mar 10, 2012 #6 Hello sarkis, List1.Get(i) returns an object, not a string. CharAt is only available for strings so if you code B4X: List1.Get(i).charAt(j) you try to get a character directly from an object - which won't work. Assing List1.Get(i) to a string is a form of type conversion (called "casting" in other languages). specci48 Upvote 0
Hello sarkis, List1.Get(i) returns an object, not a string. CharAt is only available for strings so if you code B4X: List1.Get(i).charAt(j) you try to get a character directly from an object - which won't work. Assing List1.Get(i) to a string is a form of type conversion (called "casting" in other languages). specci48
R r2d4 Member Licensed User Longtime User Mar 10, 2012 #7 Just for understanding: Do you want the ascii code of a given char? Or just the char at a specific position in a string? Upvote 0
Just for understanding: Do you want the ascii code of a given char? Or just the char at a specific position in a string?
S sarkis Member Licensed User Longtime User Mar 11, 2012 #8 get numbers from txt file generally I was in need to read numbers from txt file. in this time that were single numbers (0-9). What I did you see but how do that in a simply way ,when numbers are bigger than 9 ? Upvote 0
get numbers from txt file generally I was in need to read numbers from txt file. in this time that were single numbers (0-9). What I did you see but how do that in a simply way ,when numbers are bigger than 9 ?
R r2d4 Member Licensed User Longtime User Mar 12, 2012 #9 So you want to get numbers out of a string? Then you can use this regex: /\d+/s Click to expand... Upvote 0