vb编程计算结果1+1=11?源代码在这里,不知道错误,50分

来源:百度知道 编辑:UC知道 时间:2024/06/04 02:21:40
不知道错在哪里……
想做一个只有加法的计算器,结果1+1=11……还有,怎么把计算结果输出到text控件阿
新手阿……
Private Sub Command1_Click()
x = Text1.Text
y = Text2.Text
Form1.Print x + y
(说是这里错了)

End Sub

Private Sub Form_Load()
Dim x As Integer
Dim y As Integer
End Sub

谢谢

Private Sub Command1_Click()
Dim x As Integer
Dim y As Integer
x = Text1.Text
y = Text2.Text
Text3.Text = x + y
End Sub
后面的就不要了

Private Sub Command1_Click()
x = val(Text1.Text) '这里改一下
y = val(Text2.Text) '这里改一下
Form1.Print x + y
(说是这里错了)

End Sub

Private Sub Form_Load()
Dim x As Integer '或者把这两行放在代码窗口的最上边
Dim y As Integer
End Sub

Private Sub Command1_Click()
x = Text1.Text '这里错了,应该是x=val(text1.text),val是把字符串转换为数值,因为你要做加法运算,所以要转换
y = Text2.Text ’同上
Form1.Print x + y
(说是这里错了)

End Sub

Private Sub Form_Load()
Dim x As Integer
Dim y As Integer
End Sub

Private Sub Command1_Click()
Dim x y z As Single
x = Text1.Text
y = Text2.Text
z = x+y
Text3.Text = z

我也是初学者