求助啊。能帮我解释一下吗。详细点谢谢
Dim x1 As Single, x2 As SingleDim Y As Single
Dim n As Integer
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text + CStr(Index)
End Sub
'输入小数点时的处理办法
Private Sub Command2_Click(Index As Integer)
Text1.Text = Text1.Text + "."
End Sub
'按运算符时的处理方法
Private Sub Command3_Click(Index As Integer)
x1 = Val(Text1.Text)
Text1.Text = ""
n = Index
End Sub
'单击退格按钮时的处理方法
Private Sub Command4_Click()
Text1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)
End Sub
'单击清除按钮时的处理方法
Private Sub Command5_Click()
x1 = 0: x2 = 0: Y = 0
Text1.Text = ""
End Sub
'单击退出按钮时的处理方法
Private Sub Command6_Click()
Unload Me
End Sub
'单击"="按钮时的处理方法
Private Sub Command7_Click()
x2 = Val(Text1.Text)
On Error GoTo err1 '设置捕获错误
Select Case n
Case 0
Y = x1 + x2
Case 1
Y = x1 - x2
Case 2
Y = x1 * x2
Case 3
Y = x1 / x2
End Select
Text1.Text = CStr(Y)
Exit Sub
err1: '错误处理程序
MsgBox "您输入的数据有误,请重新输入!", 0 + 16, "错误!"
Text1.Text = ""
x1 = 0: x2 = 0: Y = 0
Exit Sub
End Sub
在这段程序代码中。。
Dim n As Integer
n = Index
为什么要有这2个部分啊。。。。求解释。这个有什么用,是什么意思?