Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP VBScript Subroutine Multiple Return Values

Posted on 2006-06-11
6
Medium Priority
?
1,017 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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/…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 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