万维景盛工程师今天为大家介绍asp之vbscript function函数返回与调用多个参数值的方法。
1. 数组方式返回多个值
<% 'dim getarr dim temp, ele temp="a,b,c,d,e" function fRtMltVal(str) 'dim rearr(3) 'rearr(0)="12312" fRtMltVal=split(str,",") '或者fRtMltVal=rearr end function for each ele in fRtMltVal(temp) response.write ele&"<br/>" next 'u als kn chc mlt ar //shawl.qiu 'getarr=fRtMltVal(temp) 'response.write getarr(0) %>
2. 类方式返回多个值
<% class cVnt public val public val1 end class function fRtMltVal() set fRtMltVal= new cVnt fRtMltVal.val="...val..." fRtMltVal.val1="...val1..." end function 'shawl.qiu code response.write fRtMltVal.val&"<br/>"&fRtMltVal.val1 %>
3. 字典方式返回多个值
<%
function fRtMltVal()
set dic=createObject("scripting.dictionary")
dic.add "val", "...val"
dic.add "val1", "...val1"
dic.add "val2", "...val2"
set fRtMltVal=dic
end function : dim dic 'shawl.qiu code
set dic= fRtMltVal()
response.write dic("val")&"<br/>"
response.write dic("val1")&"<br/>"
response.write dic("val2")
set dic=nothing
%>4. asp中的Function 是有返回值的,要调用的时候需要加call 或者 dim a a=Fname(str)
sub 是表示不需要返回值的!
5、function还可以是使用byref parameter的方式穿透式传递参数。
function changename(byval input, byref code, byref msg) xxxx end function 调用: changename input,code,msg
这种调用方法还会让函数内的所有参数值穿透传递。










442956988