Solved

How to parse a string with spaces inserted between letters

Posted on 2002-05-20
7
129 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 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
what about VB.NET? Does the split function work in VB.NET?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

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

Expert Comment

by:rspahitz
Comment Utility
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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now