Hello everybody
I need help to complete my project.
It's a calculator program. Most of the code is complete
IT SHOULD FUNCTION JUST AS THE PROGRAM CALCULATOR FOUND ON WINDOWS VISTA
I just have two problems
1)It should perform a continuous operation between numbers, without pressing the equal button. In other words my program just performs a mathematical operation between two numbers
For instance : If i click 4 * 2 + 3 and if i click equal it gives me 5, but it should give 11
2) other problem i have is that if i click a number and add/substract/multiply/or divide with another number it dissapears
For instance: if i click 4 and if i clcik + the 4 dissapears from the textbox
PLEASE HELP ME AS SOON AS POSSIBLE
THANK YOU!!!!!!!
Since it does not let me attach my file I will post my code
PS: If someone does not understand my problems. PLEASE OPEN A CALCULATOR PROGRAM that you have in your computer, and compare it to my program and you will see the 2 differences/ problems i have
Public Class frmMain
'Declare the global variables to be used throughout the form
Dim mfirst As Double
Dim msecond As Double
Dim manswer As String
' Declare the global variables for the operators: Add,Sub,Mul and DIV
Dim mbutton As Double
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
txtDisplay.Text = txtDisplay.Text & "0"
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
'Put the value 1 into the txtDisplay text box
If txtDisplay.Text = "0" Then
txtDisplay.Text = "1"
Else
txtDisplay.Text = txtDisplay.Text & "1"
End If
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
'Put the value 2 into the txtDisplay text box
If txtDisplay.Text = "0" Then
txtDisplay.Text = "2"
Else
txtDisplay.Text = txtDisplay.Text & "2"
End If
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
'Put the value 3 into the txtDisplay text box
If txtDisplay.Text = "0" Then
txtDisplay.Text = "3"
Else
txtDisplay.Text = txtDisplay.Text & "3"
End If
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
'Put the value 4 into the txtDisplay text box
If txtDisplay.Text = "0" Then
txtDisplay.Text = "4"
Else
txtDisplay.Text = txtDisplay.Text & "4"
End If
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
'Put the value 5 into the txtDisplay text box
If txtDisplay.Text = "0" Then
txtDisplay.Text = "5"
Else
txtDisplay.Text = txtDisplay.Text & "5"
End If
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
If txtDisplay.Text = "0" Then
txtDisplay.Text = "6"
Else
txtDisplay.Text = txtDisplay.Text & "6"
End If
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
If txtDisplay.Text = "0" Then
txtDisplay.Text = "7"
Else
txtDisplay.Text = txtDisplay.Text & "7"
End If
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
If txtDisplay.Text = "0" Then
txtDisplay.Text = "8"
Else
txtDisplay.Text = txtDisplay.Text & "8"
End If
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
If txtDisplay.Text = "0" Then
txtDisplay.Text = "9"
Else
txtDisplay.Text = txtDisplay.Text & "9"
End If
End Sub
Private Sub btnDot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click
txtDisplay.Text = txtDisplay.Text & "."
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'User slected the add button
mbutton = 1
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtDisplay.Text)
txtDisplay.Text = ""
End Sub
Private Sub btnSubstract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubstract.Click
mbutton = 2
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtDisplay.Text)
txtDisplay.Text = " "
End Sub
Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
mbutton = 3
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtDisplay.Text)
txtDisplay.Text = " "
End Sub
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
mbutton = 4
'Convert into a number and transfer the value from
'The text box on the form into the first number
mfirst = Val(txtDisplay.Text)
txtDisplay.Text = " "
End Sub
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click
msecond = Val(txtDisplay.Text)
Select Case mbutton
Case Is = 1
manswer = mfirst + msecond
Case Is = 2
manswer = mfirst - msecond
Case Is = 3
manswer = mfirst * msecond
Case Is = 4
manswer = mfirst / msecond
End Select
txtDisplay.Text = manswer
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
mbutton=0
txtDisplay.Text = "0"
End Sub
End Class