Page 182 - Open Soource Technologies 304.indd
P. 182
Event Driven Programming
End Sub
The following code is entered in the cmdAC_Click ( ) event procedure
Private Sub cmdAC_Click()
Current = Previous = 0
txtDisplay.Text = “”
End Sub
The below code is entered in the cmdNeg_Click( ) procedure
Private Sub cmdNeg_Click()
Current = -Current
txtDisplay.Text = Current
End Sub
The following code is entered in the click events of the cmdPlus, cmdMinus, cmdMultiply,
cmdDivide controls respectively.
Private Sub cmdDivide_Click()
txtDisplay.Text = “”
Previous = Current
Current = 0
Choice = “/”
End Sub
Private Sub cmdMinus_Click()
txtDisplay.Text = “”
Previous = Current
Current = 0
Choice = “-”
End Sub
Private Sub cmdMultiply_Click()
txtDisplay.Text = “”
Previous = Current
Current = 0
Choice = “*”
End Sub
Private Sub cmdPlus_Click()
txtDisplay.Text = “”
Previous = Current
Current = 0
Choice = “+”
End Sub
To print the result on the text box, the following code is entered in the cmdEqual_Click ( ) event
procedure.
176 LOVELY PROFESSIONAL UNIVERSITY