经典的ASP - 从函数返回一个值

经典的ASP  - 从函数返回一个值

问题描述:

我在经典的ASP接收一个值,并在功能它贯穿各种CASE语句的功能。我想要做的是返回函数值到一个变量,我可以使用。

I have a function in Classic ASP which receives a value and in the function it runs through various CASE statements. What I want to do is return the value of that function into a variable that I can use.

例如

Function whichNumber(intNumber)
SELECT CASE intNumber
CASE 1
whichNumber = "Yes"
CASE 2
whichNumber = "No"
END SELECT 
END Function

当我调用该函数在网页中通过

When I call that function in the webpage via:

whichNumber(intNumberToFunction)

我期待则变量whichNumber是不是是或否。因此,在code下一行我使用:

I am expecting then the variable "whichNumber" to be either "Yes" or "No". So the next line in the code I use:

strNumberText = whichNumber

不过的结果错误:

However that results in the error:

参数或无效的属性赋值的错误号码:whichNumber

Wrong number of arguments or invalid property assignment: 'whichNumber'

如果我回去,并在功能把下面的函数的末尾:

If I go back and in the function put the following at the end of the function:

Response.Write whichNumber

它正确地写道:无论是是或否的画面。反正是有函数的返回值给一个变量在室外使用的功能?

It correctly writes either "Yes" or "No" to the screen. Is there anyway to return the value of the function to a variable to use outside of the function?

希望这是有道理的!各地的网络阅读现在看来,这可能无法从这样?

Hopefully this makes sense! Reading around the web it seems it might not be possible to return a value from a function like this?

你不需要写​​ P>

Do you not need to write

strNumberText=whichNumber(intNumberToFunction)

该错误消息告诉你,你已经调用的函数,而不传递参数

The error message is telling you that you have called the function without passing the parameter