读取一行中的单独整数
Reading seperate integers in a line
我有一行文本和这样的整数:Text 10 9 8
到目前为止,我的代码是这样读取整数的:
1
10
109
1098
我的代码:
Dim total As String
For x = 0 To listbox1.Items.Count - 1
For Each ch As Char In listbox1.Items(x)
If Char.IsDigit(ch) Then
total = String.Concat(total & ch)
listbox1.Items.Add(total)
End If
Next
Next
我希望我的代码像这样读取整数:
10 9 8
谢谢
试试这个。
你的想法很好,你只是在错误的地方添加了 Items.add
。
Dim total As String
For x = 0 To ListBox1.Items.Count - 1
For Each ch As Char In ListBox1.Items(x)
If Char.IsDigit(ch) Then
total = String.Concat(total & ch)
End If
Next
ListBox1.Items.Add(total)
Next
End Sub
我有一行文本和这样的整数:Text 10 9 8
到目前为止,我的代码是这样读取整数的:
1
10
109
1098
我的代码:
Dim total As String
For x = 0 To listbox1.Items.Count - 1
For Each ch As Char In listbox1.Items(x)
If Char.IsDigit(ch) Then
total = String.Concat(total & ch)
listbox1.Items.Add(total)
End If
Next
Next
我希望我的代码像这样读取整数:
10 9 8
谢谢
试试这个。
你的想法很好,你只是在错误的地方添加了 Items.add
。
Dim total As String
For x = 0 To ListBox1.Items.Count - 1
For Each ch As Char In ListBox1.Items(x)
If Char.IsDigit(ch) Then
total = String.Concat(total & ch)
End If
Next
ListBox1.Items.Add(total)
Next
End Sub