?
Solved

Seach for Space in a string

Posted on 2003-03-01
4
Medium Priority
?
179 Views
Last Modified: 2010-05-01
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.  
0
Comment
Question by:Jake28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:DeAn
ID: 8049951
MsgBox Mid(Text1.Text, InStrRev(Text1.Text, " ") + 1)
0
 
LVL 3

Expert Comment

by:DeAn
ID: 8049952
Dim MyString as String
MyString = "12345 67890"
MsgBox Mid(MyString , InStrRev(MyString , " ") + 1)

' MsgBox displays "67890"
0
 

Author Comment

by:Jake28
ID: 8050008
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.

0
 
LVL 1

Accepted Solution

by:
MN_Dave earned 200 total points
ID: 8050148
Instead of this:

MsgBox Mid(MyString , InStrRev(MyString , " ") + 1)

Use this:

MsgBox Mid(MyString , InStr(MyString , " ") + 1)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question