PDA

View Full Version : Textbox1.text = Textbox1.text - "Hello"



carlbowles10
07-04-2012, 05:36 AM
Ive got the above code so it adds "Hello" to the text in the textbox, but what is the opposite to this, that will allow me to take out the word "Hello"?

Ive tried Textbox1.text = Textbox1.text - "Hello" but it doesnt work :(

I do not want Textbox1.text = " " because i do not want to clear the rest of the text in the box, just the word hello. thanks alot.

gmaxey
07-04-2012, 06:19 AM
Carl,

Giving a sensible answer is difficult if we don't really know what your overall objective is.

Option Explicit
Private Sub CommandButton1_Click()
'Append text
ActiveDocument.Variables("originalText").Value = Me.TextBox1.Text
Me.TextBox1.Text = Me.TextBox1.Text & " Hello"
End Sub
Private Sub CommandButton2_Click()
'Restore text
Me.TextBox1.Text = ActiveDocument.Variables("originalText").Value
End Sub
Private Sub UserForm_Initialize()
Me.TextBox1.Text = "Some text original text"
End Sub



Ive got the above code so it adds "Hello" to the text in the textbox, but what is the opposite to this, that will allow me to take out the word "Hello"?

Ive tried Textbox1.text = Textbox1.text - "Hello" but it doesnt work :(

I do not want Textbox1.text = " " because i do not want to clear the rest of the text in the box, just the word hello. thanks alot.

Frosty
07-04-2012, 03:16 PM
Look at the Replace function...
Textbox1.Text = Replace(Textbox1.Text, "Hello", "")