?
Solved

ASP VBScript Subroutine Multiple Return Values

Posted on 2006-06-11
6
Medium Priority
?
1,012 Views
Last Modified: 2012-06-27
Hi friends,

Can subroutines return multiple values? If so how?

And will these return values have to be returned as an array? And again, how?

Thanks :-)

Lee.
0
Comment
Question by:LeeGolding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
huji earned 1000 total points
ID: 16881795
Hi again!
The easiest way to return more than one value from a FUNCTION is to use an array output:

<%
FUNCTION returnTwoAndFour(arg)
  Dim temp(2)
  temp(0) = arg
  temp(1) = "Four"
  returnTwoAndFour = temp
END FUNCTION

Dim test(2)

Response.Write returnTwoandFour("Two")(1)
Response.Write "<BR>"
Response.Write returnTwoandFour("Two")(0)
%>
0
 

Author Comment

by:LeeGolding
ID: 16881813
Hi again :-)

What about from a Sub?

Lee.
0
 
LVL 14

Expert Comment

by:huji
ID: 16881827
Well, SUBs are not created to return values. The can modifed the variables defined outside them (let's call them global variables) but they can not return values directly. Functions are used for that.
You may declare a variable outside your SUB, of array type and enough size. Then you may fill it inside your SUB.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:huji
ID: 16881832
Like this for example:

<%
  Option Explicit
  Dim Y(2)

  SetLocalVariable

  Response.Write Y(1)

Sub SetLocalVariable
    Y(1) = "Some text"
End Sub
%>
0
 

Author Comment

by:LeeGolding
ID: 16881851
Thanks for clearing that up :-)

Lee.
0
 
LVL 14

Expert Comment

by:huji
ID: 16881860
You are very welcome. :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 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