convert it to a string and then you can get each single digit
B4X:
Dim OrgValue As Int = 12345
Log("OrgValue = "&OrgValue) ' LOGs the int
Dim StrVal As String = OrgValue ' Define string and set the value to the int just defined
Log("StrVal = "&StrVal) ' LOGs the string
For i = 0 To StrVal.Length-1 ' For each character of the string
Log("StrVal("&i&") = "&StrVal.SubString2(i,i+1)) ' log the character x from string...
Next
Dim myNum As Int = 123456
Dim myString As String = myNum
For i = 0 To myString.Length -1
Log ( "Integer" & i & "=" & myString.SubString2 (i, i +1))
Next
Edit ...... damn there's heavy traffic tonight .. lol but I'm the winner cause I went to 6
Thank to both of you (you are really fast, obviously)
however, the results are 5 strings, and I need 5 integers
In others words, I have an integer of 5 digits, and I would like to have 5 integers of only one digit.
Dim myNum As Int = 123456
Dim myString As String = myNum
Dim MyInt(myString.Length) As Int
For i = 0 To myInt.Length -1
MyInt(i) = myString.SubString2(i, i+1)
Log(MyInt (i))
Next
' here the a number is converted into its digits
'***********************************************
Dim myString As String = timevalue
Dim MyInt(myString.Length) As Int
digmax=3 ' the time has 3 digits: 020
For i=0 To (digmax-1)
Mtime(i)=0
Next
nn=0
For i =(digmax-MyInt.Length) To (digmax-1)
Mtime(i) = myString.SubString2(nn, nn+1)
nn=nn+1
Next
'************************************************
Thanks to this, if I have a number of 3 digits like 023, I will have 0,2 and 3
FJS ... I would like to understand your code better ... Can you tell me the value of 'timevalue' in the above example ? .
Does 'timevalue' always contain the same number of digits ?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.