0

I have a rather large list of data that contains 5 properties per element. The elements are separated by a ";". I want to read the elements into an array in VBScript. Seems simple enough to search for this on the big G but all clear examples assume you want to read line by line and then split the contents on a line on a ";" character. I do not care how many lines there are until the ";" I just want all the info (in this case 5 property fields) for each element to be in one array element.

Source file looks like this:

element1 property1 = blah
element1 property2 = blah
element1 property3 = blah
element1 property4 = blah
element1 property5 = blah
;element2 property1 = blah
element2 property2 = blah
element2 property3 = blah
element2 property4 = blah
element2 property5 = blah
;element3 property1 = blah
element3 property2 = blah
element3 property3 = blah
element3 property4 = blah
element3 property5 = blah

What I want to have happen is that my VBScript array(0) be

"element1 property1 = blah
element1 property2 = blah
element1 property3 = blah
element1 property4 = blah
element1 property5 = blah"

Any ideas on how to do this. I have made several attempts at the SPLIT function using stuff like

array = Split(objTextFile.Readline , ";")

But to no avail.

1
  • Where's your data? In a text file? In a string variable? Commented Jan 12, 2009 at 19:06

1 Answer 1

8
array = Split(objTextFile.ReadAll(), ";")
Sign up to request clarification or add additional context in comments.

3 Comments

Wow, okay that is neato. I did not know VBScript had a ReadAll option. However when I run this I get a "Type Mismatch" error on that line. I have declared my array and set its size correctly.
Don't set the size ahead of time.
Aha! thanks a bunch for that. I got a little ahead of myself there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.