Link to home
Start Free TrialLog in
Avatar of Jake28
Jake28

asked on

Seach for Space in a string

I'm new to VB and I need to know how to extract text from a string after a space is detected.

For example "123 456" would result in "456"

or "12345 6789" would result in "6789"

Thank you.  
Avatar of DeAn
DeAn

MsgBox Mid(Text1.Text, InStrRev(Text1.Text, " ") + 1)
Dim MyString as String
MyString = "12345 67890"
MsgBox Mid(MyString , InStrRev(MyString , " ") + 1)

' MsgBox displays "67890"
Avatar of Jake28

ASKER

I should have explained my question better.

DeAn's code works fine:

Dim MyString as String
MyString = "12345 67890"
MsgBox Mid(MyString , InStrRev(MyString , " ") + 1)

But what if I have several spaces in my string.

For example: from "123 456 7890" I would want "456 7890" as the result. The number of spaces in the string varies but I always want the remainder after the first space.

ASKER CERTIFIED SOLUTION
Avatar of MN_Dave
MN_Dave
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial