【发布时间】:2015-03-22 21:53:31
【问题描述】:
这真的很奇怪:
Dim i As Integer
Dim s As String = "48;55;50"
Dim numbers() As String = Split(s, ";")
For Each number In numbers
i = Integer.Parse(number)
Next
这适用于数字中的第一项 (48),但不适用于第二个数字 (55)。我得到一个 FormatException。
尝试使用 CInt 而不是 Integer.Parse。甚至尝试使用 s.Split 而不是 Split。
我真的不明白。谢谢:)
【问题讨论】:
-
您是否尝试在分配
i的行上设置断点? -
是的,我做到了。检查所有变量。这根本没有意义。
-
遇到断点时
numbercontain 做了什么? -
首先 i 设置为 0(默认)。然后是第一次运行后的48。
-
但是
number包含什么?