You are on page 1of 4

Public Class Form1

002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017

'Declare the global variables to be used throughout the


form
Dim mfirst As Single
Dim msecond As Single
Dim manswer As Single
' Declare the global variables for the operators: Add,Sub,Mul and DIV
Dim mbutton As Integer
'Change the sign of the number from + or - or vice versa
' Depending on its state now they show in txtNUMBER text box
Dim Signstate As Boolean
Private Sub cmdCLEAR_Click()
'Remove the values in the txtNUMBER text box
End Sub
Private Sub cmdEXIT_Click()
Me.Close()
End Sub

Private Sub cmd0_Click(ByVal sender As System.Object, ByVal


System.EventArgs) Handles cmd0.Click
019
'Put the value 0 into the txtNUMBER text box
020
txtNUMBER.Text = txtNUMBER.Text & "0"
021
End Sub
022
Private Sub cmd1_Click(ByVal sender As System.Object, ByVal
023
System.EventArgs) Handles cmd1.Click
024
'Put the value 0 into the txtNUMBER text box
025
txtNUMBER.Text = txtNUMBER.Text & "1"
026
End Sub
027
Private Sub cmd2_Click(ByVal sender As System.Object, ByVal
028
System.EventArgs) Handles cmd2.Click
029
'Put the value 0 into the txtNUMBER text box
030
txtNUMBER.Text = txtNUMBER.Text & "2"
031
End Sub
032
Private Sub cmd3_Click(ByVal sender As System.Object, ByVal
033
System.EventArgs) Handles cmd3.Click
034
'Put the value 0 into the txtNUMBER text box
035
txtNUMBER.Text = txtNUMBER.Text & "3"
036
End Sub
037
Private Sub cmd4_Click(ByVal sender As System.Object, ByVal
038
System.EventArgs) Handles cmd4.Click
039
'Put the value 0 into the txtNUMBER text box
040
txtNUMBER.Text = txtNUMBER.Text & "4"
041
End Sub
042
Private Sub cmd5_Click(ByVal sender As System.Object, ByVal
043
System.EventArgs) Handles cmd5.Click
018

e As

e As

e As

e As

e As

e As

044
045
046
047

'Put the value 0 into the txtNUMBER text box


txtNUMBER.Text = txtNUMBER.Text & "5"
End Sub

Private Sub cmd6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmd6.Click
049
'Put the value 0 into the txtNUMBER text box
050
txtNUMBER.Text = txtNUMBER.Text & "6"
051
End Sub
052
Private Sub cmd7_Click(ByVal sender As System.Object, ByVal e As
053
System.EventArgs) Handles cmd7.Click
054
'Put the value 0 into the txtNUMBER text box
055
txtNUMBER.Text = txtNUMBER.Text & "7"
056
End Sub
057
Private Sub cmd8_Click(ByVal sender As System.Object, ByVal e As
058
System.EventArgs) Handles cmd8.Click
059
'Put the value 0 into the txtNUMBER text box
060
txtNUMBER.Text = txtNUMBER.Text & "8"
061
End Sub
062
Private Sub cmd9_Click(ByVal sender As System.Object, ByVal e As
063
System.EventArgs) Handles cmd9.Click
064
'Put the value 0 into the txtNUMBER text box
065
txtNUMBER.Text = txtNUMBER.Text & "9"
066
End Sub
067
Private Sub cmdSIGN_Click(ByVal sender As System.Object, ByVal e As
068
System.EventArgs) Handles cmdSIGN.Click
069
Dim MINUSVALUE
070
'Sign state = false on load of form
071
If txtNUMBER.Text = "-" & txtNUMBER.Text Then
072
MsgBox("error start again")
073
End If
074
If Signstate = False Then
075
txtNUMBER.Text = "-" & txtNUMBER.Text
076
Signstate = True
077
Else
078
'SignState = True
079
080
MINUSVALUE = Val(txtNUMBER.Text)
081
'Value now positive
082
MINUSVALUE = Val("-1" * MINUSVALUE)
083
txtNUMBER.Text = MINUSVALUE
084
Signstate = False
085
End If
086
End Sub
087
048

088
089
090
091
092
093
094
095
096
097

Private Sub cmdSUBTRACT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdSUBTRACT.Click
'User slected the minus button
mbutton = 2
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtNUMBER.Text)
txtNUMBER.Text = ""
End Sub

Private Sub cmdDOT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdDOT.Click
099
txtNUMBER.Text = txtNUMBER.Text & "."
100
End Sub
101
Private Sub cmdADD_Click(ByVal sender As System.Object, ByVal e As
102
System.EventArgs) Handles cmdADD.Click
103
'User slected the add button
104
mbutton = 1
105
'Convert into a number and transfer the value from
106
'The text box on the form into the first number
107
mfirst = Val(txtNUMBER.Text)
108
109
txtNUMBER.Text = ""
110
End Sub
111
Private Sub cmdDIVIDE_Click(ByVal sender As System.Object, ByVal e As
112
System.EventArgs) Handles cmdDIVIDE.Click
113
'User slected the Divide button
114
mbutton = 4
115
'Convert into a number and transfer the value from
116
'The text box on the form into the first number
117
mfirst = Val(txtNUMBER.Text)
118
119
txtNUMBER.Text = ""
120
End Sub
121
Private Sub cmdEQUALS_Click(ByVal sender As System.Object, ByVal e As
122
System.EventArgs) Handles cmdEQUALS.Click
123
msecond = Val(txtNUMBER.Text)
124
125
Select Case mbutton
126
Case Is = 1
127
manswer = mfirst + msecond
128
Case Is = 2
129
manswer = mfirst - msecond
130
Case Is = 3
131
manswer = mfirst * msecond
098

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

Case Is = 4
manswer = mfirst / msecond
End Select
txtNUMBER.Text = manswer
End Sub
Private Sub cmdMULTIPLY_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdMULTIPLY.Click
'User slected the multiply button
mbutton = 3
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtNUMBER.Text)
txtNUMBER.Text = ""
End Sub
Private Sub cmdCLEAR_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCLEAR.Click
mbutton = 0
txtNUMBER.Text = ""
manswer = Nothing
End Sub

Private Sub cmdCE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdCE.Click
155
txtNUMBER.Text = ""
156
End Sub
157
End Class
154

You might also like