neo_lover2000
May 28, 2009, 08:41 PM
I already finish a very simple calculator,actually it has only four buttons.
at first its working fine but when add another feature its not working anymore. What I want to do is when press 1 then press + then press 1 and press + again it should add the first two number get ready to add another number. I don't know how to work it out I'm new vb6
need somebody to revise my program.
thanks
Dim first As Long
Dim second As Long
Dim sign As String
Dim Calculated As Boolean
Private Sub Command1_Click()
TextDisplay.Text = TextDisplay.Text + Command1.Caption
End Sub
Private Sub cmdPlus_Click()
Calculated = True
If Calculated = True Then
first = Val(TextDisplay.Text)
TextDisplay.Text = ""
second = Val(TextDisplay.Text)
first = first + second
TextDisplay.Text = first
second = 0
Else
first = Val(TextDisplay.Text)
TextNum1.Text = first
TextDisplay.Text = ""
sign = cmdPlus.Caption
End If
End Sub
Private Sub cmdC_Click()
TextDisplay.Text = ""
TextNum1.Text = ""
TextNum2.Text = ""
TextFlag.Text = ""
End Sub
Private Sub cmdEq_Click()
second = Val(TextDisplay.Text)
TextNum2.Text = second
If sign = "+" Then
TextDisplay = first + second
End If
End Sub
at first its working fine but when add another feature its not working anymore. What I want to do is when press 1 then press + then press 1 and press + again it should add the first two number get ready to add another number. I don't know how to work it out I'm new vb6
need somebody to revise my program.
thanks
Dim first As Long
Dim second As Long
Dim sign As String
Dim Calculated As Boolean
Private Sub Command1_Click()
TextDisplay.Text = TextDisplay.Text + Command1.Caption
End Sub
Private Sub cmdPlus_Click()
Calculated = True
If Calculated = True Then
first = Val(TextDisplay.Text)
TextDisplay.Text = ""
second = Val(TextDisplay.Text)
first = first + second
TextDisplay.Text = first
second = 0
Else
first = Val(TextDisplay.Text)
TextNum1.Text = first
TextDisplay.Text = ""
sign = cmdPlus.Caption
End If
End Sub
Private Sub cmdC_Click()
TextDisplay.Text = ""
TextNum1.Text = ""
TextNum2.Text = ""
TextFlag.Text = ""
End Sub
Private Sub cmdEq_Click()
second = Val(TextDisplay.Text)
TextNum2.Text = second
If sign = "+" Then
TextDisplay = first + second
End If
End Sub