A Conversation for Website Developer's Forum
ASP/VBScript Help Needed!
Bogie Started conversation Aug 6, 2003
I need to split a value from a recordset into two separate fields at the last space. For example:
I have a FullName field in my recordset:
"David John Bailey"
I want to split into into Forename and Surname fields at the last space:
"David John"
"Bailey"
How do I do this using ASP/VBScript? I know it has something to do with the InStr command, but can't find any books which explain this. Can anyone help?
B.
ASP/VBScript Help Needed!
Felonious Monk - h2g2s very own Bogeyman Posted Aug 6, 2003
Try using the InStrRev function to locate the last space in the string, then the Mid and Left function to return the end and beginning.
spacepos = InStrRev(name, " ")
firstnames = Left(name, spacepos -1)
lastnames = Mid(name, spacepos + 1)
You can use Trim() to shear off any leading or traling spaces if you want
FM
ASP/VBScript Help Needed!
Bogie Posted Aug 6, 2003
Thanks MF!
It worked perfectly. The 10000 records were re-imported into a new database and cleaned up with only 10 record glitches... easily fixed.
Thanks so much.
B.
PS: Found this online a couple of minutes ago:
http://www.w3schools.com/vbscript/default.asp
Key: Complain about this post
ASP/VBScript Help Needed!
More Conversations for Website Developer's Forum
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."