Left Split

A

awwtau

Is there a function that allows you to do a left split, or equivalent, on
data up to a space rather than upto a specified number of characters?

ie A234 BFG, the space can be in different positions so specifying the
number of characters wouldn't work.

Any ideas would be appreciated.

Alan
 
D

DBS

What you're is the "Split" function. It parses a string based on the
delimiter you specify, and returns an zero-based array of strings.

'==========================
Public Function UseSplit()

Dim arrParsedString() As String

arrParsedString = Split("A234 BFG", " ")

MsgBox arrParsedString(0) 'Show a message box with the message "A234"
MsgBox arrParsedString(1)'Show a message box with the message "BFG"

End Function
'==========================

Hope that helps!

DBS (David Staas)
 
B

Brendan Reynolds

? Left$("A234 BFG",InStr(1,"A234 BFG", " ")-1)
A234

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Top