Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to parse a string with spaces inserted between letters

Posted on 2002-05-20
7
Medium Priority
?
142 Views
Last Modified: 2010-05-02
I want to parse strings with spaces inserted between the three character long letters and add them into an array. What will be the most efficient method. Following is the example of the types of strings I want to parse:

"ESM  ESX  E8C            "

Any quick code will be appreciated.

Thanks
0
Comment
Question by:smkkaleem
7 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 7021640
Use split:

Dim aryBits() As String
Dim MyString As String
MyString = "ESM ESX E8C"
aryBits = Split(MyString," ")
Msgbox aryBits(0) & vblf & aryBits(1) & vblf & aryBits(2)


0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7021643
This only works in VB6 though so if you have an older version it will not. I can give you a function that works in vb5 if you want.
0
 
LVL 2

Author Comment

by:smkkaleem
ID: 7021657
what about VB.NET? Does the split function work in VB.NET?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Joe_Griffith
ID: 7021675
The split function works exactly the same in VB.NET
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7022025
If the codes contain multiple spaces between them, you may need to filter them out first with something like this:

strCodeList = "ESM  ESX  E8C            "

' get rid of leading and trailing spaces
strCodeList = Trim$(strCodeList)

' Replace all double-spaces with single spaces
while instr(strCodeList, "  ") > 0
  strCodeList = Replace(strCodeList, "  ", " ")
wend

' Now put into an array
dim strCodeArray() as string
strCodeArray = split(strCodeList, " ")
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7818282
Hi smkkaleem,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

smkkaleem, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7909750
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

916 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