asp -- passing an array to a sub

I have a subprocedure:

sub send_email(userid,parts)

Open in new window


The parts argument receives an array.  Here is how I am calling the sub:

send_email(user_id,matchingParts)

Open in new window


matchingParts is an array that i am trying to give to the send_email function.

I do a test and use the Ubound() function to check the upper bound of the array before putting it into the subprocedure and it shows that there are indeed items in the array.  When I check the ubound() value of the array parts in the subprocedure, I get 0 as the upper bound.  So suddenly all the elements in my array are removed just by passing the array.

What is going on and how can i pass the array?
nickgross19Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
I found the issue..

you wrote:
send_email(user_id,matchingParts)

but in the code you build:
mathcingParts

hc vs ch

just a typo
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try calling without the brackets:
send_email user_id,matchingParts
0
 
nickgross19Author Commented:
tried it, and once the array is passed, the ubound() function returns 0.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you please show the full code of that function?
0
 
nickgross19Author Commented:
sub send_email(userid,parts)
	dim htmlParts
	dim xyz
	response.Write("passed ubound: "&ubound(parts)&"<br>")

Open in new window


As you can see, right away i get a 0 returned by the ubound() function.  The only thing that happens before this is two dim statemtns
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sounds ok, can you please show the relevant code that builds the array, and calls send_mail function?
0
 
nickgross19Author Commented:
This is the code that builds the array:
do while not ngrs2.eof
		if part_ic = "" then
			part_ic = 0
		end if
		ReDim Preserve mathcingParts(part_ic)
		mathcingParts(part_ic) = ngrs2.Fields("ID")
		part_ic = part_ic + 1
		ngrs2.MoveNext
	loop

Open in new window

0
 
nickgross19Author Commented:
I got it to work somehow, i don't know what i was doing wrong...  

Thanks for your help.
0
 
sybeCommented:
An array with Ubound = 0 has one element. Arrays start counting at 0. If you have an empty array, it will return -1 on Ubound.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.