Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Break big delimited string into little strings

Posted on 1999-07-06
5
Medium Priority
?
123 Views
Last Modified: 2010-05-02
I need to break a sting, delimited by ';' into little
strings to be put into elements on a struct.

The string looks like this 1;2;2;2;2 .......  can be up
to 50 elements long when extracted, but no element will be bigger than 1 character.  

How is this easily acheived?

So easy in SQR, not so easy here
0
Comment
Question by:xbd
[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
  • 4
5 Comments
 
LVL 2

Accepted Solution

by:
BeedleGuis earned 150 total points
ID: 1522289
dim strtemp as string, intPos as integer
dim colStrings as new collection
'get the first substring
strtemp = left(strmain,1)
colstrings.add strtemp
'loop to get the rest
intPos = instr(intpos,strMain,";",vbtextcompare)
while intpos > 0
    strtemp = mid(strMain,intpos+1,1)
    colStrings.add strtemp
wend


0
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1522290
oops . . my fault, should be this:

Dim strtemp As String, intPos As Integer, strmain As String
Dim colStrings As New Collection
'get the first substring
strtemp = Left(strmain, 1)
colStrings.Add strtemp
'loop to get the rest
intPos = InStr(intPos + 1, strmain, ";", vbTextCompare)
While intPos > 0
    strtemp = Mid(strmain, intPos + 1, 1)
    colStrings.Add strtemp
    intPos = InStr(intPos + 1, strmain, ";", vbTextCompare)
Wend

where strmain is your delimited string
0
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1522291
or, instead of adding to a collection, just set your structure elements in the loop.
0
 
LVL 3

Expert Comment

by:KhollAD
ID: 1522292
In VB6, you can use the Split command.

use : NewArray = Split(BigDelimitedString, DelimiterChar)

example : A = Split("20;30;40;50;60", ";")
0
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1522293
wow, you learn somthing every day  :-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

671 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