【发布时间】:2017-05-24 23:16:52
【问题描述】:
我在 TextBox 中添加 2 个整数时遇到问题。如果我加 1 + 1,我得到 11。
请帮忙..
这是我的代码:
Private Sub cmdAdd_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = CInt(TextBox1.Text)
b = CInt(TextBox2.Text)
c = CInt(TextBox3.Text)
TextBox3.Value = TextBox1.Value + TextBox2.Value
c = a + b
End Sub
我使用了这段代码,它也可以工作:
x = CDbl(txtSurveyYes.Value) + CDbl(txtSurveyNo.Value)
txtTotal.Value = x
【问题讨论】:
-
cint尝试而不是 val,您正在连接 -
这样的? a = CInt(TextBox1.Text) b = CInt(TextBox2.Text) c = CInt(TextBox3.Text)
-
谢谢你,Nathan..它现在可以工作了..