本文介绍了VBScript函数返回多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

有没有办法在不使用

数组的情况下从函数返回多个值?字典对象会更好用吗?


-

Roland Hall

/ *这些信息是希望分发的将是有用的,但

没有任何保证;甚至没有适销性的暗示保证

或特定用途的适用性。 * /

Technet脚本中心 -

WSH 5.6文档 -

MSDN Library -

Is there a way to return multiple values from a function without using an
array? Would a dictionary object work better?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

推荐答案




s = Func()

Response.Write(s)


函数Func()

Const A =" a"

Const B =" ; b"

Const C =" c"

Func = A& "," &安培; B& "," &安培; C $ / $
结束功能


或者你认为CSV字符串是一个数组?


是否是Dcitionary "更好"取决于你想要什么?b $ b b ...



s = Func()
Response.Write(s)

Function Func()
Const A = "a"
Const B = "b"
Const C = "c"
Func = A & "," & B & "," & C
End Function

Or do you consider a CSV string an array?

Whether a Dcitionary would be "better" depends on what are you trying to
do...





还有第三种方法:制作自己的数据类型通过定义一个具有您需要的所有值的类




Class MyClass

Public Value1

公共价值2

公共价值3

结束班级


函数ReturnMyClass

Dim c

set ReturnMyClass = new MyClass

ReturnMyClass.Vlalue1 =" 1"

ReturnMyClass.Vlalue2 =" 2"

结束功能


Jan



There is a third alternative: Make your own "datatype" by defining a class
that has all values you need:

Class MyClass
Public Value1
Public Value2
Public Value3
End Class

Function ReturnMyClass
Dim c
set ReturnMyClass = new MyClass
ReturnMyClass.Vlalue1 = "1"
ReturnMyClass.Vlalue2 = "2"
End Function

Jan



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

1403页,肝出来的..

09-08 10:54