I am working on making a calculator in vb.6
the issue is:
i am using three text boxes one for for the first number, another for the second number, last one for the result
so if type "1" in the first txt, and "1" in thew second txt, then clicking a cmdPlus (+), the result "2" will appear in the third txt.
the problem is that i wanna use just one textbox so that if u type "1" then u click the command (+), number 1 will be saved and the textbox will be clear again for putting another number, then u put another number and then press command (=) and result will appear in the same textbox.
so my main question is how to use one textbox for putting the first number and the second number and the result instead of 3 textboxes.
my code with the 3 textboxes is something like this:
Private Sub txt1_Change() 'here u put first number End Sub Private Sub txt2_Change() 'here u put second number End Sub Private Sub txtAnswer_Change() ' here result will appear if u click on (+) command End Sub Private Sub cmdPlus_Click() txtAnswer.Text = Val(txt1.Text) + Val(txt2.Text) End Sub 'notice that i can only type the number from the keyboard 'because if i put a command button for number 1 for example, ' i can make it only appear in one text box but not the other ' some thing like this: Private Sub cmd1_Click() If txt1.Text = "" Then txt1.Text = 1 ElseIf txt1.Text <> "" Then txt1.Text = txt1.Text & 1 End If 'number one will appear only in txt1 and i dont know 'how to make it appear in txt2 once u click inside it ' thats why i wanna use just one text box for 'putting numbers and getting results
hopefully someone can help me with this
1. how to make cmd1 represent a number 1 in txt1 OR txt2 depends on which txt i click inside?
2. how to use only one textbox for putting numbers and getting results instead of 3?