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:


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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try calling without the brackets:
send_email user_id,matchingParts
nickgross19Author Commented:
tried it, and once the array is passed, the ubound() function returns 0.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you please show the full code of that function?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sounds ok, can you please show the relevant code that builds the array, and calls send_mail function?
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

Open in new window

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

Thanks for your help.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I found the issue..

you wrote:

but in the code you build:

hc vs ch

just a typo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.