Android Question string array to int array

msfactory

Member
Licensed User
Longtime User
I'm sorry
It has posted using the translation software so I can not speak English
I do not know how to convert to int array from a string array
I want to know is the way!
This code, the following error will appear
java.lang.NumberFormatException: Invalid double: ""
Sub test
Dim text As String
Dim b(100) As Int
Dim a(100) As String
text = "_ABC_DEF_GHI_JKL_MNO ・・・・・・・・・・・・・・・・・・・・"
a =Regex.Split("_",text)
For i = 0 To a.Length -1
b(i) = a(i)
Next
End Sub
 
You cannot store a string in an integer array when some of the elements are strings. If, for instance you have this:
text ="1_876_721_35", then it will work because all elements are numbers.
This works:
Code: Copy
Dim text AString
Dim b(100) As Int
Dim a(100) As String
text ="1_876_721_35"
a =Regex.Split("_",text)
For i = 0 To a.Length -1
   b(i) = a(i)
  Log(b(i))
Next


This will also work:
Code: Copy
Dim text As String
Dim b(100) As Int
Dim a(100) As String
text = "_ABC_DEF_GHI_JKL_MNO"
a =Regex.Split("_",text)
For i = 0 To a.Length -1
  b(i) = a(i).Length
  Log(b(i))
Next
 
Upvote 0
Back
Top