Trim Text

S

Sean

If the text "C:\Temp" is entered into a text box (including the quotes), is
there a way using VBA code to remove the quotes. The quote marks will always
be the first and last characters of any string.

Thanks for the help.
 
H

Helmut Weber

Hi Sean,

if it is a textbox on a userform,
then like this:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
UserForm1.TextBox1.Text = _
Replace(UserForm1.TextBox1.Text, chr(34), "")
End Sub

Note that you need at least a second control,
to be able to exit Textbox1.

HTH


Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Hal Tz

Not sure at what point you want to do this: whenever a key is hit in the
textbox? whenever the textbox loses focus? whenever another button is hit?
Also not sure what you want to do with the trimmed string. But the mechanics
or stripping are:


1. get the text box contents into a string, like s1
2. set another string like this: s2 = Mid(s1, 2, Len(s1) - 2)

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top