VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



calculator

by Beginners luck Bert (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 16th December 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

calculator

API Declarations


You will need a numer of buttons and text boxses
hide: text2 - text6, check1 and 2

Rate calculator



Private Sub Command6_Click()

End Sub

Private Sub cmd0_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "0"
Else: Text1.Text = ""
Text1.Text = Text1 & "0"
End If
End Sub

Private Sub Cmd1_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "1"
Else: Text1.Text = ""
Text1.Text = Text1 & "1"
End If
End Sub

Private Sub Command1_Click()

End Sub

Private Sub cmd2_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "2"
Else: Text1.Text = ""
Text1.Text = Text1 & "2"
End If
End Sub

Private Sub cmd3_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "3"
Else: Text1.Text = ""
Text1.Text = Text1 & "3"
End If
End Sub

Private Sub cmd4_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "4"
Else: Text1.Text = ""
Text1.Text = Text1 & "4"
End If
End Sub

Private Sub cmd5_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "5"
Else: Text1.Text = ""
Text1.Text = Text1 & "5"
End If
End Sub

Private Sub cmd6_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "6"
Else: Text1.Text = ""
Text1.Text = Text1 & "6"
End If
End Sub

Private Sub cmd7_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "7"
Else: Text1.Text = ""
Text1.Text = Text1 & "7"
End If
End Sub

Private Sub cmd8_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "8"
Else: Text1.Text = ""
Text1.Text = Text1 & "8"
End If
End Sub

Private Sub cmd9_Click()
If Text6.Text = "" Then
Text1.Text = Text1 & "9"
Else: Text1.Text = ""
Text1.Text = Text1 & "9"
End If
End Sub

Private Sub cmddelen_Click()
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
If Text5.Text = "" Then
    If Text6.Text = "" Then
        Text5.Text = Text1.Text
        Text1.Text = ""
    Else:
        Text5.Text = Text6.Text
        Text1.Text = ""
    End If
Else:
Text5.Text = Text6.Text
Text1.Text = ""
    End If
End Sub

Private Sub cmddelet_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub

Private Sub Cmdkomma_Click()
    If Check1.Value = Checked Then
        MsgBox (" maar 1 komma in 1 getal mogelijk"), vbInformation, EROR
    End If
    If Check1.Value = Unchecked Then
        Text1.Text = Text1 & "."
        Check1.Value = Checked
    End If
End Sub

Private Sub cmdmaal_Click()
Text2.Text = ""
Text3.Text = ""
Text5.Text = ""
If Text4.Text = "" Then
    If Text6.Text = "" Then
        Text4.Text = Text1.Text
        Text1.Text = ""
    Else:
        Text4.Text = Text6.Text
        Text1.Text = ""
    End If
Else:
Text4.Text = Text6.Text
Text1.Text = ""
    End If
End Sub

Private Sub cmdmin_Click()
Text2.Text = ""
Text4.Text = ""
Text5.Text = ""
If Text3.Text = "" Then
    If Text6.Text = "" Then
        Text3.Text = Text1.Text
        Text1.Text = ""
    Else:
        Text3.Text = Text6.Text
        Text1.Text = ""
    End If
Else:
Text3.Text = Text6.Text
Text1.Text = ""
    End If
End Sub

Private Sub cmdnegatief_Click()
If Check2.Value = Checked Then
        MsgBox (" maar 1 Min in 1 getal mogelijk"), vbInformation, EROR
    End If
    If Check2.Value = Unchecked Then
        Text1.Text = Text1 & "-"
        Check2.Value = Checked
    End If
End Sub

Private Sub cmdplus_Click()
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
If Text2.Text = "" Then
    If Text6.Text = "" Then
        Text2.Text = Text1.Text
        Text1.Text = ""
    Else:
        Text2.Text = Text6.Text
        Text1.Text = ""
    End If
Else:
Text2.Text = Text6.Text
Text1.Text = ""
    End If
End Sub

Private Sub Cmdstop_Click()
b = MsgBox("wilt u zeker stoppen met rekenen", vbYesNo, "Einde")
If b = vbYes Then
End
ElseIf b = vbNo Then
Form1.Refresh
End If

End Sub

Private Sub cmduitkomst_Click()
If Text2.Text <> "" Then
        If Text6.Text = "" Then
            Text6.Text = Text1.Text
            Text1.Text = Str(Val(Text2.Text) + Val(Text1.Text))
        Text6.Text = Text1.Text
        Else:
            Text6.Text = Text1.Text
            Text1.Text = Str(Val(Text2.Text) + Val(Text6.Text))
            Text6.Text = Text1.Text
        End If
    ElseIf Text3.Text <> "" Then
        If Text6.Text = "" Then
            Text6.Text = Text1.Text
            Text1.Text = Str(Val(Text3.Text) - Val(Text1.Text))
        Text6.Text = Text1.Text
        Else:
            Text6.Text = Text1.Text
            Text1.Text = Str(Val(Text3.Text) - Val(Text6.Text))
            Text6.Text = Text1.Text
        End If
    ElseIf Text4.Text <> "" Then
        If Text6.Text = "" Then
            Text6.Text = Text1.Text
            Text1.Text = Str(Val(Text4.Text) * Val(Text1.Text))
        Text6.Text = Text1.Text
        Else:
            Text6.Text = Text1.Text
            Text1.Text = Str(Val(Text4.Text) * Val(Text6.Text))
            Text6.Text = Text1.Text
        End If
    ElseIf Text5.Text <> "" Then
       If Text1.Text = 0 Then
       MsgBox ("GE KUNT NIET DELEN DOOR NUL KIEKE !!"), vbCritical, "GAAT NIET"
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Else:
            If Text6.Text = "" Then
               Text6.Text = Text1.Text
                Text1.Text = Str(Val(Text5.Text) / Val(Text1.Text))
                Text6.Text = Text1.Text
            Else:
                Text6.Text = Text1.Text
                Text1.Text = Str(Val(Text5.Text) / Val(Text6.Text))
                Text6.Text = Text1.Text
            End If
        End If
End If
End Sub

Private Sub Form_Load()
A = MsgBox("klaar om te rekenen", vbQuestion + vbYesNo, "Rekenen maar")
If A = vbYes Then
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = "0"
ElseIf A = vbNo Then
End
End If

End Sub


Private Sub Text1_Change()
Text7.Text = Str(Val(Text1.Text) / (40.3399))
End Sub



Download this snippet    Add to My Saved Code

calculator Comments

No comments have been posted about calculator. Why not be the first to post a comment about calculator.

Post your comment

Subject:
Message:
0/1000 characters