Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array of an array

Status
Not open for further replies.

mcpeekj

Vendor
Sep 21, 2001
105
0
0
I'm trying to loop through an array and create another array with only the rows where a phrase exists. gmmastros was kind enough to help me with the instr to do the search, and it works great when I'm doing anything but trying to create and populate another array. Here's the code.

Code:
dim alldata_sub()
FOR rowcounter= 0 TO alldatarows
	id=alldata(0,rowcounter)
    lastsent=alldata(1,rowcounter)
    subject=alldata(2,rowcounter)
    posts=alldata(3,rowcounter)

	for j = 0 to alldatarows
		if (InStr(1, alldata(2,j), "Automated Failed", vbTextCompare) > 0)  Then
			'ReDim preserve alldata_sub(count)
			alldata_sub(0,count) = alldata(1,j) 
			alldata_sub(1,count) = alldata(3,j)  
			count = count + 1
		exit for
		end if
	next
next

I'm declaring alldata_sub() because I get a type mismatch when I leave the parentheses off. The error I'm getting with the above code is:

Microsoft VBScript runtime error '800a0009'
Subscript out of range

Help?
 
Try this:
Code:
ReDim preserve alldata_sub(2, count)
alldata_sub(0,count) = alldata(1,j) 
alldata_sub(1,count) = alldata(3,j)

I generally use variables named something other than the function name as working variables, then assign the working variable to the function name as the last statement, but that's just personal preference.

Lee
 
...because it's a 2-dimensional array. I knew it was going to be something fundamental.

Thanks Lee, works like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top