Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

take out specific text

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
US
How would i take out certain text in a variable.

For example...

name = "My Name is George"

i want to take the text "My Name is " out of name.
 
Dim InputString As String
Dim PartToTakeOut As String

InputString = "My Name is George"
PartToTakeOut = "My Name is "

MsgBox Replace(InputString,PartToTakeOut,"")

Swi
 
For the example you've given, simply using Right$(name, 6) will return George. If you want a more general solution, you're going to have to give us some context. Are you trying to make sure that the name variale never contains anything more than someone's first name? Or is it something else?
 
As Fiaban99 states we will probably need some addional info. to be able to give you a complete answer. If the example you provide is how the string is always formatted you could also use something like this:

Dim Name as String

Name = "My Name is George"

MsgBox Mid$(Name,12)

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top