清朝皇帝陵墓几个被盗:用VB语言编写程序(2):

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/02 18:04:28
设计一个窗体,使用一个按钮”输入”来接受用户输入的两个数,使用另外四个按钮”加”,”减”,”乘”,”除”来执行这两个数的加,减乘,除运算,利用标签显示结果.

考试帮助啊!

Dim a, b As Single

Private Sub Command1_Click()
a = Val(InputBox("输入数1"))
b = Val(InputBox("输入数2"))
End Sub

Private Sub Command2_Click(Index As Integer)
Dim c As Single
Select Case Index
Case 0: c = a + b
Case 1: c = a - b
Case 2: c = a * b
Case 3: c = a / b
End Select
Label1 = a & Command2(Index).Caption & b & "=" & c
End Sub

Private Sub Form_Load()
Command1.Caption = "输入"
Command2(0).Caption = "+"
Command2(1).Caption = "-"
Command2(2).Caption = "*"
Command2(3).Caption = "/"
End Sub