连减时,被减数为0时 错在哪

来源:互联网 发布:网络技能大赛答案 编辑:程序博客网 时间:2024/05/14 23:22

代码如下:

Dim s As DoubleDim k1 As DoubleDim k2 As DoubleDim n As Integer Private Sub Command1_Click(Index As Integer) Select Case IndexCase 1Text1.Text = Text1.Text & 1Case 2Text1.Text = Text1.Text & 2Case 3Text1.Text = Text1.Text & 3Case 4Text1.Text = Text1.Text & 4Case 5Text1.Text = Text1.Text & 5Case 6Text1.Text = Text1.Text & 6Case 7Text1.Text = Text1.Text & 7Case 8Text1.Text = Text1.Text & 8Case 9Text1.Text = Text1.Text & 9Case 0Text1.Text = Text1.Text & 0Case 10Text1.Text = Text1.Text & "."End SelectEnd SubPrivate Sub Command10_Click()k1 = Val(Text1.Text)If k1 <= 0 ThenMsgBox "您输入的数据有误,请重新输入!", vbOKOnly + vbCritical, "错误!"Exit SubEnd Ifs = Log(k1)Text1.Text = ""Text1.Text = sEnd SubPrivate Sub Command11_Click()k1 = Val(Text1.Text)s = Sin(k1 * 3.1415926 / 180)Text1.Text = sEnd SubPrivate Sub Command12_Click()k1 = Val(Text1.Text)s = Cos(k1 * 3.1415926 / 180)Text1.Text = sEnd SubPrivate Sub Command13_Click()k1 = Val(Text1.Text)s = Tan(k1 * 3.1415926 / 180)Text1.Text = sEnd SubPrivate Sub Command14_Click()k1 = Val(Text1.Text)s = Atn(k1 * 3.1415926 / 180)Text1.Text = sEnd SubPrivate Sub Command15_Click()k1 = Val(Text1.Text)j = 1For i = 1 To k1 j = i * j Next i Text1.Text = jEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Command3_Click()k2 = Val(Text1.Text)Select Case nCase 0s = s + k2Case 1s = s - k2Case 2s = k1 * k2Case 3s = k1 / k2End SelectText1.Text = CStr(s)End SubPrivate Sub Command4_Click(Index As Integer)k1 = Val(Text1.Text)Text1.Text = ""n = IndexIf n = 0 Thens = s + k1Exit SubEnd IfIf n = 1 Then If s = 0 Then  s = k1 - s  Else   s = s - k1   End IfExit SubEnd IfEnd SubPrivate Sub Command5_Click()Text1.Text = ""k1 = 0k2 = 0s = 0End SubPrivate Sub Command6_Click()While Len(Text1.Text) - 1 >= 0Text1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)Exit SubWendEnd SubPrivate Sub Command7_Click()s = Sqr(Val(Text1.Text))Text1.Text = sEnd SubPrivate Sub Command8_Click()k1 = Val(Text1.Text)s = k1 * k1Text1.Text = sEnd SubPrivate Sub Command9_Click()k1 = Val(Text1.Text)s = k1 * k1 * k1Text1.Text = sEnd Sub


0 0
原创粉丝点击