|
-
Mar 20th, 2002, 07:00 PM
#1
Thread Starter
Fanatic Member
Array Headache
I am looping through a fiel and getting the first character of every line and wanting to put it into an array. So far I have looped through there but how do I build the array dynamically?
do while TS.AtEndOfStream = false
strValue = left(Ts.Readline, 1)
strValue = strValue & ","
'now this is where I would build my array?
loop
-
Mar 20th, 2002, 07:07 PM
#2
Addicted Member
use
Code:
redim preserve arrayname(ubound(arrayname) + 1)
arrayname(ubound(arrayname)) = Whatever!
-
Mar 20th, 2002, 07:10 PM
#3
Addicted Member
Ok..let me clear that up because I don't think you understood the first time!
VB Code:
Dim strArray(0) As String
Do while TS.AtEndOfStream = false
strValue = left(Ts.Readline, 1)
strValue = strValue & ","
Redim Preserve strArray(ubound(strArray) + 1)
strArray(ubound(strArray)) = "WHATEVER"
Loop
-
Mar 20th, 2002, 07:11 PM
#4
Thread Starter
Fanatic Member
So it should look like this?
do while TS.AtEndOfStream = false
strValue = left(Ts.Readline, 1)
strValue = strValue & ","
redim preserve strFLettArray(ubound(strFLettArray) + 1)
strFLettArray(ubound(strFLettArray)) = strValue
loop
I am getting an error, Subscript out of range: UBound
-
Mar 20th, 2002, 07:13 PM
#5
Thread Starter
Fanatic Member
Sorry it crashes on the line Redim....
-
Mar 20th, 2002, 07:16 PM
#6
Addicted Member
Did u use my code??
It works fine. I think you didn't declare the variable properly. Copy and paste my code and see if it gives any error!
-
Mar 20th, 2002, 07:23 PM
#7
Thread Starter
Fanatic Member
I was in the thread when you were posting it so know I did not get that cvode but now I have put it in. I am getting a different error though:
This array is fixed or temporarily locked
This is on the same line (redim)
Here is what I have:
Dim strArray2(0)
Do while TS.AtEndOfStream = false
strValue = left(Ts.Readline, 1)
strValue = strValue & ","
Redim Preserve strArray2(ubound(strArray2) + 1)
strArray2(ubound(strArray2)) = "WHATEVER"
Loop
-
Mar 20th, 2002, 07:41 PM
#8
Thread Starter
Fanatic Member
Note** This is vbScript, I am sorry that I did not tell you that but it slipped my mind. Sorry...
-
Mar 20th, 2002, 07:52 PM
#9
Thread Starter
Fanatic Member
Is what I am doing even logical?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|