Option Explicit Dim plus As Boolean Dim minus As Boolean Dim times As Boolean Dim divide As Boolean Dim Neg1 As Boolean Private Sub clear_Click() Text1 = "" Text2 = "" plus = False minus = False times = False divide = False Neg1 = False Text1.Visible = True Text2.Visible = False equal.SetFocus End Sub Private Sub command1_Click() plus = True Text1.Visible = False Text2.Visible = True equal.SetFocus End Sub Private Sub Command6_Click() End Sub Private Sub Command2_Click() minus = True Text1.Visible = False Text2.Visible = True equal.SetFocus End Sub Private Sub Command3_Click() times = True Text1.Visible = False Text2.Visible = True equal.SetFocus End Sub Private Sub Command4_Click() divide = True Text1.Visible = False Text2.Visible = True equal.SetFocus End Sub Private Sub Command5_Click() If plus = False And minus = False And times = False And divide = False Then Text1 = Val(Text1) ^ 2 Else Text2 = Val(Text2) ^ 2 End If equal.SetFocus End Sub Private Sub dot_Click() If plus = False And minus = False And times = False And divide = False Then Text1 = Text1 & "." End If If plus = True Or minus = True Or times = True Or divide = True Then Text2 = Text2 & "." End If equal.SetFocus End Sub Private Sub eight_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "8" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "8" End If equal.SetFocus End Sub Private Sub equal_Click() If Text1 = "" Or Text2 = "" Then MsgBox "Please Enter In Both Numbers." Else Text1.Visible = True Text2.Visible = False If plus = True And minus = False And divide = False And times = False Then Text1 = (Text1.Text) + Val(Text2.Text) Text2 = "" End If If plus = False And minus = True And times = False And divide = False Then Text1 = Val(Text1) - Val(Text2) Text2 = "" End If If plus = False And minus = False And times = True And divide = False Then Text1 = Val(Text1) * Val(Text2) Text2 = "" End If If plus = False And minus = False And times = False And divide = True Then If Text2 = "0" Then MsgBox "Cant divide by zero!" Else Text1 = Val(Text1) / Val(Text2) Text2 = "" End If End If End If plus = False minus = False times = False divide = False End Sub Private Sub five_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "5" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "5" End If equal.SetFocus End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 43 Then command1_Click End If If KeyAscii = 45 Then Command2_Click End If If KeyAscii = 42 Then Command3_Click End If If KeyAscii = 47 Then Command4_Click End If If KeyAscii = 61 Then equal_Click End If If KeyAscii = 8 Then clear_Click End If If KeyAscii = 48 Then zero_Click End If If KeyAscii = 49 Then one_Click End If If KeyAscii = 50 Then two_Click End If If KeyAscii = 51 Then three_Click End If If KeyAscii = 52 Then four_Click End If If KeyAscii = 53 Then five_Click End If If KeyAscii = 54 Then six_Click End If If KeyAscii = 55 Then seven_Click End If If KeyAscii = 56 Then eight_Click End If If KeyAscii = 57 Then nine_Click End If If KeyAscii = 46 Then dot_Click End If If KeyAscii = 113 Then quit_Click End If If KeyAscii = 110 Then negative_Click End If If KeyAscii = 115 Then Command5_Click End If If KeyAscii = 114 Then sqroot_Click End If End Sub Private Sub four_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "4" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "4" End If equal.SetFocus End Sub Private Sub memory_Click() If plus = False And minus = False And times = False And divide = False Then lblmemory = Text1 Else lblmemory = Text2 End If equal.SetFocus End Sub Private Sub memoryclear_Click() lblmemory = "" equal.SetFocus End Sub Private Sub negative_Click() If plus = False And minus = False And times = False And divide = False Then If Neg1 = False Then Text1 = "-" & Text1 Neg1 = True Else Text1 = Int(Text1) - Int(Text1) * 2 Neg1 = False End If End If If plus = True Or minus = True Or times = True Or divide = True Then If Neg1 = False Then Text2 = "-" & Text2 Neg1 = False Else Text2 = Int(Text2) - Int(Text2) * 2 Neg1 = True End If End If equal.SetFocus End Sub Private Sub nine_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "9" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "9" End If equal.SetFocus End Sub Private Sub one_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "1" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "1" End If equal.SetFocus End Sub Private Sub plus_Click() End Sub Private Sub quit_Click() Unload Me End Sub Private Sub recallmemory_Click() If plus = False And minus = False And times = False And divide = False Then Text1 = lblmemory Else Text2 = lblmemory End If equal.SetFocus End Sub Private Sub seven_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "7" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "7" End If equal.SetFocus End Sub Private Sub six_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "6" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "6" End If equal.SetFocus End Sub Private Sub sqroot_Click() If Text1 = "" Then MsgBox "Please Enter A Number To Sqaure Root" Else If plus = False And minus = False And times = False And divide = False Then Text1 = Sqr(Text1) Else Text2 = Sqr(Text2) End If End If equal.SetFocus End Sub Private Sub three_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "3" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "3" End If equal.SetFocus End Sub Private Sub two_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "2" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "2" End If equal.SetFocus End Sub Private Sub zero_Click() If plus = False And minus = False And times = False And divide = False Then Text1.Text = Text1.Text & "0" End If If plus = True Or minus = True Or times = True Or divide = True Then Text2.Text = Text2.Text & "0" End If equal.SetFocus End Sub