How do you do an appending code?

MarcusBell

Member
Joined
Feb 1, 2005
Messages
12
Programming Experience
Beginner
How do you do an appending code?

for example. if I had in a program a 1,2,3 button and a plus operator button and two display txt boxes. I want to retain what I a madding in the one text box box. for example if I have 1+2+2 = 5, how ever I want keep this information display in thte one text box, and if I was to ad a - button and use it with the about number example 1+2+2 =5 -1-2 = 3 (ignor the = just for show) I know you have to append the code but not sure how to

txtOutPut.text = ? retaining information in Output text box. Below are code for the + and 7 buttons so you can see what I hav done.

Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
If clearDisplay Then
txtInput.ResetText()
clearDisplay = False
End If
txtInput.Text = txtInput.Text + sender.Text
If txtInput.Text = True Then
txtOutput.Text = txtInput.Text
End If

Private Sub btnPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlus.Click
operand1 = Val(txtOutput.Text)
operator = "+"
clearDisplay =
True
If txtInput.Text = True Then
txtOutput.Text = txtOutput.Text & "+"
End If


I hope this maks sense?

In Short I want to keep the calculation I am doing in one text box that is visiable as you are preforming calculatings, until you hit the clear button

Regards

Marcus
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
To keep the text that's currently in a textBox and append something to it, use the &= operator:
'Before, txtInput.Text = "1+2+2"
txtInput.text &= "+"
'now txtInput.Text = "1+2+2+"
 
Top Bottom