经典的ASP - 从函数返回一个值 [英] Classic ASP - Returning a value from a function

查看:236
本文介绍了经典的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?

推荐答案

你不需要写

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

这篇关于经典的ASP - 从函数返回一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆