Solved

asp -- passing an array to a sub

Posted on 2011-09-28
9
272 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:nickgross19
  • 4
  • 4
9 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
please try calling without the brackets:
send_email user_id,matchingParts
0
 

Author Comment

by:nickgross19
Comment Utility
tried it, and once the array is passed, the ubound() function returns 0.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
can you please show the full code of that function?
0
 

Author Comment

by:nickgross19
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
sounds ok, can you please show the relevant code that builds the array, and calls send_mail function?
0
 

Author Comment

by:nickgross19
Comment Utility
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
 

Author Comment

by:nickgross19
Comment Utility
I got it to work somehow, i don't know what i was doing wrong...  

Thanks for your help.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
 
LVL 28

Expert Comment

by:sybe
Comment Utility
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now