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
split it then convert them dim s as string = "1 3 5 6 7 9" dim slist() as string = s.Split(CChar(" ")) dim ilist(slist.Length -1) as integer
for i as integer = 0 to slist.Length - 1 ilist(i) = Convert.ToInt32(slist(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 = "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
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
dim slist() as string = s.Split(CChar(" "))
dim ilist(slist.Length -1) as integer
for i as integer = 0 to slist.Length - 1
ilist(i) = Convert.ToInt32(slist(i))
next
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 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