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

Retrieving everything before Space in field 2

Status
Not open for further replies.

timtom

Programmer
Jul 12, 2001
78
GB
Hi. I've got a field with people's full name inside. I want the first name only to do something with.

How do I get "Adam" from "Adam Smith" and "Liz" from "Liz Taylor"?

Thanks for any help you may be able to give
Sarah
User_timtom.jpg
WASN'T FIT ENOUGH FOR THE POLICE FORCE
 
dim theName, nameArray, firstName
theName = "Adam Smith"
nameArray = split(theName," ")
firstName = ubound(nameArray)

response.write("My first name is " & firstName)
penny.gif
penny.gif
 
firstname should actually be ubound(namearray(0)) but that was easy enough to work out.

Thanks link, much appreciated
:)
User_timtom.jpg
WASN'T FIT ENOUGH FOR THE POLICE FORCE
 
actually, it should be

nameArray(lbound(nameArray))

sorry bout that. fast fingers.

:)
paul
penny.gif
penny.gif
 
odd, either of the ubound or lbounds only return the number of position in the array the information lays at...for instance:
firstName = lbound(nameArray)

returns a 0 (zero) for me. If I use timtom's approach, the ubound and lbound features won't work at all because you're already specifying the placeholder, so what works for me is:
firstName = nameArray(0)
lastName = nameArray(1)

Perhaps it's just my server or else I missed somthing? -Ovatvvon :-Q
 
ok, after I submitted this now I see Paul's other message, tried that and that does work as well. :) -Ovatvvon :-Q
 
right, it was totally my bad. What I was trying to do was what I posted last, thereby specifying I wanted the lowest position of the array like:

nameArray(lbound(nameArray))

in other words:

nameArray(0)

Likewise, if you ask for:

nameArray(ubound(nameArray))

it would give you the last name. In other words:

nameArray(1)

lbound() returns the lower boundary of an array
ubound() returns the upper boundary of an array

:)
paul
penny.gif
penny.gif
 
Some serious message criss-crossing going on here. I missed your very last post, as well.

LOL
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top