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.
For example "123 456" would result in "456"
or "12345 6789" would result in "6789"
Thank you.
MsgBox Mid(Text1.Text, InStrRev(Text1.Text, " ") + 1)
Dim MyString as String
MyString = "12345 67890"
MsgBox Mid(MyString , InStrRev(MyString , " ") + 1)
' MsgBox displays "67890"
MyString = "12345 67890"
MsgBox Mid(MyString , InStrRev(MyString , " ") + 1)
' MsgBox displays "67890"
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.