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!

Could anyone please help me with a code that could reverse a variable?

Status
Not open for further replies.

dixiedarlin

Technical User
Dec 10, 2002
1
US
How would I get Doe, John from input of John Doe
 
Here's a sneaky way to do it if you use a comma

var$ = "Doe, John"
OPEN "aaa.tmp" FOR OUTPUT AS #1
PRINT #1, var$
CLOSE
OPEN "aaa.tmp" FOR INPUT AS #1
INPUT #1, last$
INPUT #1, first$
CLOSE
KILL "aaa.tmp"
PRINT first$,last$
fullname$ = first$ + " " + last$


hehehe - very unconventional
 
This will work nicely with the comma+space in the text:

Function Fixname$ (x)
Fixname$ = Left$(Mid$(x + " , ", InStr(x + " , ", ", ") + 2), InStr(Mid$(x + ", ", InStr(x + ", ", ", ") + 3) + " ", " ")) + Left$(x + ", ", InStr(x + ", ", ", ") - 1)
End Function

This makes "Smith, Bob" into "Bob Smith" and "ABC Supply" stays as "ABC Supply"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top