【发布时间】:2015-02-10 22:07:05
【问题描述】:
我创建了一个程序,该程序仅从包含字符串的文本文件以及列表框中成功读取整数。例如: 文本文件包含:
- 泰勒 7
- 丹尼尔 2
- 迈克 6
- 罗里 9
然后列表框将显示:7269。 但是我计划将这些数字从最高到最低排序(反之亦然),为了做到这一点,我想尝试将每个数字存储在列表框中的新行上,但我不确定如何完成此操作。 我用来读取整数的代码是:
Dim intOnly As String = IO.File.ReadAllText(File_1)
Dim intValue As String = String.Empty
For Each c As Char In intOnly
If IsNumeric(c) Then
intValue += c
End If
Next
ListBox3.Items.Add(intValue)
End Sub
【问题讨论】:
-
不要在数学中使用字符串!
-
点赞:
If IsNumeric(c) Then ListBox3.Items.Add(c)? -
呵呵,我是个新手,但字符串不会更好,因为它将整数与字符串分开?
-
我想如果你想保留数字并且不想把它们加起来那可以开始
-
@Index 几乎适用于我想要做的事情!问题是虽然它使 '10' 在不同的行上显示为 '1' 和 '0',是否有解决方法?
标签: vb.net listbox integer streamreader