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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with grabbing strings

Status
Not open for further replies.

mcallaghan

IS-IT--Management
Mar 22, 2005
43
US
I have a question on using string I am trying to create a script that will take a name such as John Smith and create a variable that says jsmith.

The code i have just isnt working

mAssigned = "John Smith")
pos=instr(mAssigned," ")
msgbox pos ("Works Fine")

first=left(mAssigned,1)
msgbox first("Works Fine")

last=left(mAssigned,pos+1,3)
msgbox last ("Doesnt work")

If you can help it will be most appreciated.

Thanks
 
Perhaps some more information on your goal would help. What you are trying to do seems logically suspect.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
the Left function only takes 2 parameters!

try

Right(mAssigned, Len(mAssigned) - pos)
 
Why not simply this ?
a = Split(mAssigned)
newvar = LCase(Left(a(0), 1) & a(1))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Disregard my earlier statement about the logic being suspect. It turns out that my comprehension of the issue is the only thing suspect in this thread. I agree with PHV's solution for what it is worth.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top