【发布时间】:2017-01-23 09:47:16
【问题描述】:
Select Case dlg
Case Windows.Forms.DialogResult.Yes
If TextBox12.Text = "" Then
Dim a, b, c As Integer
a = TextBox7.Text
b = TextBox8.Text //my problem
c = TextBox11.Text
TextBox12.Text = a + b - c
End If
If TextBox6.Text = "" Then
TextBox6.Text = "-"
End If
我不知道如何解决这个错误:
从字符串“”到类型“整数”的转换无效
【问题讨论】:
-
您不能将空字符串转换为 Int。在尝试分配给 int 变量之前,您应该检查文本框是否为空
-
开启Option Strict On。从长远来看,这将有所帮助。你需要
Integer.TryParse(TextBox7.Text, a) -
Khakim,你应该考虑接受这个问题的答案之一。对您有帮助的答案将是显而易见的选择。它可以帮助该帖子的未来读者,还可以帮助您获得一点代表。
标签: vb.net visual-studio