Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Trim Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sean - 10 Aug 2005 20:01 GMT
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.
Helmut Weber - 10 Aug 2005 20:56 GMT
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"
Hal Tz - 10 Aug 2005 20:56 GMT
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.
Signature

Hal

> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.