Vba 在2文本框中添加2个数字
在文本框中添加2个整数时遇到问题。如果我加1+1,我得到11 请帮忙 这是我的密码:Vba 在2文本框中添加2个数字,vba,add,Vba,Add,在文本框中添加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 =
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,正如Nathan_Sav所说,您当前正在连接字符串 您需要执行以下操作:
Private Sub cmdAdd_Click()
TextBox3.Value = CInt(TextBox1.Value) + CInt(TextBox2.Value)
End Sub
cint
try而不是val,你是在连接这样的东西吗?a=CInt(TextBox1.Text)b=CInt(TextBox2.Text)c=CInt(TextBox3.Text)谢谢你Nathan.它现在可以用了Hexie,非常感谢你.它和Nathan说的一样有效.我还添加了我在头条文章中使用的那一个.请看。。