VB程序:
Dim a, b As Boolean Dim c As Integer
Dim d, x, y, z As Single
Private Sub Command16_Click()’ -----------------------------------------对应“+/-” If Text1.Text > -1 And Text1.Text < 0 Then Text1.Text = \"0\" & (-Text1.Text)
ElseIf Text1.Text >= 0 And Text1.Text < 1 Then Text1.Text = \"-\" & Text1.Text Else: Text1.Text = -Text1.Text End If b = True End Sub
Private Sub Command1_Click()’-----------------------------------------对应“0” If b = True Or Text1.Text = \"0.\" Then Text1.Text = \"0.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"0\" Else: Text1.Text = Text1.Text & \"0\" End If End Sub
Private Sub Command2_Click()’-----------------------------------------对应“1” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"1.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"1.\"
Else: Text1.Text = Text1.Text & \"1\" End If End Sub
Private Sub Command3_Click()’-----------------------------------------对应“2” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"2.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"2.\" Else: Text1.Text = Text1.Text & \"2\" End If End Sub
Private Sub Command4_Click()’-----------------------------------------对应“3” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"3.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"3.\" Else: Text1.Text = Text1.Text & \"3\" End If End Sub
Private Sub Command5_Click()’-----------------------------------------对应“4” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"4.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"4.\" Else: Text1.Text = Text1.Text & \"4\" End If End Sub
Private Sub Command6_Click()’-----------------------------------------对应“5” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"5.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"5.\" Else: Text1.Text = Text1.Text & \"5\" End If End Sub
Private Sub Command7_Click()’-----------------------------------------对应“6” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"6.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"6.\" Else: Text1.Text = Text1.Text & \"6\" End If End Sub
Private Sub Command8_Click()’-----------------------------------------对应“7” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"7.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"7.\" Else: Text1.Text = Text1.Text & \"7\" End If End Sub
Private Sub Command9_Click()’-----------------------------------------对应“8” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"8.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"8.\" Else: Text1.Text = Text1.Text & \"8\" End If End Sub
Private Sub Command10_Click()’-----------------------------------------对应“9” If b = True Or (a = False And Text1.Text = \"0.\") Then Text1.Text = \"9.\" b = False
ElseIf a = False Then
Text1.Text = Val(Text1.Text) & \"9.\" Else: Text1.Text = Text1.Text & \"9\" End If End Sub
Private Sub Command15_Click()’-----------------------------------------对应“.” If b = True Then Text1.Text = \"0.\" b = False
End If a = True End Sub
Private Sub Command17_Click()’-----------------------------------------对应“sqrt” If Text1.Text >= 0 And Text1.Text < 1 Then Text1.Text = \"0\" & Sqr(Val(Text1.Text)) ElseIf Text1.Text >= 1 Then
Text1.Text = Sqr(Val(Text1.Text)) End If b = True End Sub
Private Sub Command19_Click()’-----------------------------------------对应“1/x” If Text1.Text <> 0 Then
If Text1.Text > -1 And Text1.Text < 1 Then Text1.Text = 1 / Text1.Text ElseIf Text1.Text >= 1 Then
Text1.Text = \"0\" & (1 / Text1.Text)
Else: Text1.Text = \"-0\" & (-1 / Text1.Text) End If End If b = True End Sub
Private Sub Command11_Click()’-----------------------------------------对应“/” x = Text1.Text c = 1
Text1.Text = \"0.\" a = False End Sub
Private Sub Command12_Click()’-----------------------------------------对应“*” x = Text1.Text c = 2
Text1.Text = \"0.\" a = False End Sub
Private Sub Command13_Click()’-----------------------------------------对应“+” x = Text1.Text c = 3
Text1.Text = \"0.\" a = False
End Sub
Private Sub Command14_Click()’-----------------------------------------对应“-” x = Text1.Text c = 4
Text1.Text = \"0.\" a = False End Sub
Private Sub Command18_Click()’-----------------------------------------对应“%” x = Text1.Text c = 5
Text1.Text = \"0.\" a = False End Sub
Private Sub Command20_Click()’-----------------------------------------对应“=” y = Text1.Text If c = 1 Then If y <> 0 Then z = x / y End If
ElseIf c = 2 Then z = x * y
ElseIf c = 3 Then z = x + y
ElseIf c = 4 Then z = x - y
ElseIf c = 5 Then z = x Mod y End If
If z > -1 And z < 0 Then Text1.Text = \"-0\" & (-z) ElseIf z > 0 And z < 1 Then Text1.Text = \"0\" & z Else: Text1.Text = z End If c = 0 a = False b = True End Sub
Private Sub Command21_Click()’-----------------------------------------对应“backspace” d = Right(Text1.Text, 1)
If d = \".\" Then
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 2) & \".\" a = False Else
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) End If End Sub
Private Sub Command22_Click()’-----------------------------------------对应“CE” Text1.Text = \"0.\" a = False End Sub
Private Sub Command23_Click()’-----------------------------------------对应“C” Text1.Text = \"0.\" x = 0 a = False End Sub
因篇幅问题不能全部显示,请点此查看更多更全内容