Solved

ASP VBScript Subroutine Multiple Return Values

Posted on 2006-06-11
6
1,005 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 250 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

Technology Partners: 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 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 informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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