msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extracting the last word in a string

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
robboll



Joined: 07 Jan 2008
Posts: 1

PostPosted: Sun Jan 06, 2008 7:21 pm    Post subject: Extracting the last word in a string Reply with quote

What is the best method of extracting the last word in a string?
Example Table/Field1:

Field1
There once was a time
The old man sat
Two peas in a pod
One bird in the hand

function to extract the last word:

FunResult
time
sat
pod
hand

If it were the first word it would be: mid(Field1,1,instr(1,field1,"
"))

Thanks for any suggestions!

RBollinger

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Ken Halter



Joined: 04 Oct 2007
Posts: 4150

PostPosted: Sun Jan 06, 2008 7:58 pm    Post subject: Re: Extracting the last word in a string Reply with quote

"robboll" wrote in message @d21g2000prf.googlegroups.com...
> What is the best method of extracting the last word in a string?
> Example Table/Field1:
>
> Field1
> There once was a time
> The old man sat
> Two peas in a pod
> One bird in the hand
>
> function to extract the last word:
>
> FunResult
> time
> sat
> pod
> hand
>
> If it were the first word it would be: mid(Field1,1,instr(1,field1,"
> "))
>


Check out the InstrRev function... checks from the end of the string.

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group