怎样用VB6.0做计算器 ?

只需要四则运算,不要太复杂,我才初三..
2024-12-31 04:56:23
推荐回答(1个)
回答1:

最最简单的就这样。。。
3个TextBox,4个按钮

Private Sub Command1_Click() ' 加
Text3.Text = Int(Text1.Text) + Int(Text2.Text)
End Sub

Private Sub Command2_Click() '减
Text3.Text = Int(Text1.Text) - Int(Text2.Text)
End Sub

Private Sub Command3_Click() '乘
Text3.Text = Int(Text1.Text) * Int(Text2.Text)
End Sub

Private Sub Command4_Click() '除
If Int(Text2.Text) <> 0 Then
Text3.Text = Int(Text1.Text) / Int(Text2.Text)
Else
MsgBox "除数不能为0", , "提示"
End If
End Sub