Dim str As String = "12345"
Dim c() As Char = System.Text.Encoding.ASCII.GetChars(System.Text.Encoding.ASCII.GetBytes(str))
Dim result(c.Length - 1) As Integer
For i As Integer = 0 To c.Length - 1
result(i) = Integer.Parse(c(i))
Next
用ArrayList多好啊。不用考虑长度和类型
Dim S As String
Dim result As New ArrayList()
For each S in Split("1 3 5 6 7 9")
result.Add(Convert.ToInt32(S))
Next
测试:
for i as integer = 0 to result.Count-1
Response.Write(result(i).GetType())
next
结果:
System.Int32System.Int32System.Int32System.Int32System.Int32System.Int32
Dim str As String = "1 3 5 6 7 9"
Dim ary() As String
ary = str.Split(" "c)
Dim ary1(ary.Length - 1) As Int32
Dim i As Int32
For i = 0 To ary.Length
ary1(i) = Convert.ToInt32(ary(i))
Next