VB制作计算器 求代码

需要可以换行 有按钮的 十分感谢 求全代码
2025-01-07 00:57:50
推荐回答(3个)
回答1:

请在窗体上放2个textbox(文本框)和4个commandbutton(命令按钮)和1个label(标签),再输入以下代码 :
Dim a%, b%, c%
Private Sub Command1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a + b
Label1.Caption = Label1.Caption & c
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a * b
Label1.Caption = Label1.Caption & c
End Sub
Private Sub Command3_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - b
Label1.Caption = Label1.Caption & c
End Sub
Private Sub Command4_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a / b
Label1.Caption = Label1.Caption & c
End Sub
给出这个程序

回答2:

select case f
case "+"
msgbox val(text1)+val(text2)
case "-"
msgbox val(text1)-val(text2)
case “*”
msgbox val(text1)*val(text2)
case "/"
msgbox val(text1)\val(text2)
end select

回答3:

vb计算器 整个工程代码提供