查看文章 |
上机报告7—简易计算器
(1) 设置属性 (2) 设计代码,如下: Private Sub Form_Load() Option1.Value = True '默认为“+”运算 End Sub Private Sub Command1_Click() '“计算”按钮 Dim a As Single, b As Single, t As Single, s As String a = Val(Text1.Text) b = Val(Text2.Text) Select Case True Case Option1.Value ' + 运算 s = "+" t = a + b Case Option2.Value ' - 运算 s = "-" t = a - b Case Option3.Value ' * 运算 s = "*" t = a * b Case Option4.Value ' / 运算 s = "/" t = a / b End Select Text3.Text = a & s & b & "=" & t End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub
Private Sub Command3_Click() end End Sub |

