问题描述:
计算器的全部 好难
那位大哥解答下
谢谢了 `````
问题解答:
Dim XIAOSHU As Boolean
Dim FUHAO As Byte
Dim FIRSTNUMBER As Double
Dim DENGHAO As Boolean
Private Sub Command1_Click()
If Text1.Text = "" Then
Exit Sub
End If
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub
Private Sub Command10_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "1"
Else
Text1.Text = "1"
DENGHAO = False
End If
End Sub
Private Sub Command11_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "2"
Else
Text1.Text = "2"
DENGHAO = False
End If
End Sub
Private Sub Command12_Click(Index As Integer)
Text1.Text = Sqr(Text1.Text)
End Sub
Private Sub Command13_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "3"
Else
Text1.Text = "3"
DENGHAO = False
End If
End Sub
Private Sub Command14_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "4"
Else
Text1.Text = "4"
DENGHAO = False
End If
End Sub
Private Sub Command15_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "5"
Else
Text1.Text = "5"
DENGHAO = False
End If
End Sub
Private Sub Command16_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "6"
Else
Text1.Text = "6"
DENGHAO = False
End If
End Sub
Private Sub Command17_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "7"
Else
Text1.Text = "7"
DENGHAO = False
End If
End Sub
Private Sub Command18_Click()
If Not DENGHAO Then
Text1.Text = Text1.Text + "8"
Else
Text1.Text = "8"
DENGHAO = False
End If
End Sub
Private Sub Command19_Click()
If Not fenghao Then
Text1.Text = Text1.Text + "9"
Else
Text1.Text = "9"
DENGHAO = False
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
XIAOSHU = False
End Sub
Private Sub Command20_Click()
FIRSTNUMBER = Val(Text1.Text)
FUHAO = 3
Text1.Text = ""
XIAOSHU = False
End Sub
Private Sub Command21_Click()
FIRSTNUMBER = Val(Text1.Text)
FUHAO = 2
Text1.Text = ""
XIAOSHU = False
End Sub
Private Sub Command22_Click()
FIRSTNUMBER = Val(Text1.Text)
FUHAO = 1
Text1.Text = ""
XIAOSHU = False
End Sub
Private Sub Command23_Click()
If (Sgn(Val(Text1.Text))) = 1 Then
Text1.Text = "-" + Text1.Text
Exit Sub
End If
If (Sgn(Val(Text1.Text))) = -1 Then
Text1.Text = Abs(Val(Text1.Text))
End If
End Sub
Private Sub Command24_Click()
If Text1.Text = "" Then
Text1.Text = "0"
End If
If Not XIAOSHU Then
Text1.Text = Text1.Text + "."
XIAOSHU = True
End If
End Sub
Private Sub Command25_Click()
If FUHAO = 1 Then
Text1.Text = FIRSTNUMBER + Val(Text1.Text)
End If
If FUHAO = 2 Then
Text1.Text = FIRSTNUMBER - Val(Text1.Text)
End If
If FUHAO = 3 Then
Text1.Text = FIRSTNUMBER * Val(Text1.Text)
End If
If FUHAO = 4 Then
If Val(Text1.Text) = 0 Then
MsgBox "分母不能为“0”"
Text1.Text = ""
Else
Text1.Text = FIRSTNUMBER / Val(Text1.Text)
End If
End If
End Sub
Private Sub Command26_Click()
Text1.Text = Val(Text1.Text) / 100 & "% "
End Sub
Private Sub Command27_Click()
Text1.Text = Val(1 / Text1.Text)
End Sub
Private Sub Command3_Click()
Text1.Text = ""
End Sub
Private Sub Command4_Click()
Text1.Text = Sin(Text1.Text)
End Sub
Private Sub Command5_Click()
Text1.Text = Cos(Text1.Text)
End Sub
Private Sub Command6_Click()
Text1.Text = Tan(Text1.Text)
End Sub
Private Sub Command7_Click()
Text1.Text = Atn(Text1.Text)
End Sub
Private Sub Command8_Click()
FIRSTNUMBER = Val(Text1.Text)
FUHAO = 4
Text1.Text = ""
XIAOSHU = False
End Sub
Private Sub Command9_Click()
If Text1.Text <> "" Then
Text1.Text = Text1.Text + "0"
End If
End Sub
Private Sub VBGUAN_Click()
Form2.Show
End Sub
Private Sub VBKE_Click()
Form3.Show
Form1.Hide
End Sub