B4X:
Error description: '(' expected.
Error occurred on line: 266
ConvertFromBase10 = strRes
Word: =
B4X:
Private Sub ConvertToBase10 (strNumberToConvert As String , intFromBase As Int )
Dim valid As String
Dim lett As String
Dim indx As Long
Dim res As Long
Dim i As Long
Dim alpha As String
'
If strNumberToConvert.Length = 0 Then
Exit
End If
'
alpha = "123456789ABCDEF"
res = 0
valid = alpha.SubString (intFromBase - 1)
strNumberToConvert = strNumberToConvert.ToUpperCase
[COLOR=rgb(226, 80, 65)] ConvertToBase10 = ""[/COLOR]
For i = 1 To strNumberToConvert.Length
lett = strNumberToConvert.SubString2 (i, 0)
indx = valid.IndexOf( lett)
If indx = 0 And lett <> "0" Then
Log ("invalid data")
Exit
End If
res = intFromBase * res + indx
Next
[COLOR=rgb(226, 80, 65)] ConvertToBase10 = res[/COLOR]
End Sub
Private Sub ConvertFromBase10 (inRes As String, intToBase As Int)
Dim res As Long
Dim A As Long
Dim C As Long
Dim strRes As String
Dim alpha As String
alpha = "123456789ABCDEF"
res = inRes
strRes = ""
A = (res / intToBase)
C = res - A * intToBase
Do While (A + C > 0)
If C = 0 Then
strRes = "0" & strRes
Else
strRes = alpha.SubString2 (C, 0) & strRes
End If
res = A
A = (res / intToBase)
C = res - A * intToBase
Loop
[COLOR=rgb(226, 80, 65)] ConvertFromBase10 = strRes[/COLOR]
End Sub