[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1024
  • Last Modified:

ASP VBScript Subroutine Multiple Return Values

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
LeeGolding
Asked:
LeeGolding
  • 4
  • 2
1 Solution
 
hujiCommented:
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
 
LeeGoldingAuthor Commented:
Hi again :-)

What about from a Sub?

Lee.
0
 
hujiCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
hujiCommented:
Like this for example:

<%
  Option Explicit
  Dim Y(2)

  SetLocalVariable

  Response.Write Y(1)

Sub SetLocalVariable
    Y(1) = "Some text"
End Sub
%>
0
 
LeeGoldingAuthor Commented:
Thanks for clearing that up :-)

Lee.
0
 
hujiCommented:
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!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now