我想调用一个“返回”的函数。几个值 [英] I would like to call a function that "returned" several values

查看:71
本文介绍了我想调用一个“返回”的函数。几个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用一个返回的函数。几个值 - 所有

都与表单上的过程需求相关。我这么做了。
明白FN会返回一个值。


我想知道,这是一个雇用用户定义的好地方输入?


FN将驻留在全局模块中。当被调用时,它确实返回

一个被认为是最重要的值。但是当它正在运行时,

它会计算几个更重要的值,否则在处理时需要在调用函数中重新计算


返回那里。评论?

I would like to call a function that "returned" several values - all
of which are relevant to the needs of a procedure on a form. I do
understand that FN''s return a single value.

I''m wondering, is this a good place to employ a user-defined Type?

The FN would reside in a global module. When called, it does return
one value considered to be the most important. But while it''s running,
it does calculate several more important values that would otherwise
have to be REcalculated in the calling function when processing
returns there. Comments?

推荐答案

最简单的方法是将一些额外的参数*传递给*函数,

并将它们设置为那里。然后调用例程可以检查那些

变量的值。


用户定义的类型对于某些情况也是一个很好的解决方案。请参阅:

函数的多个返回值 - 用户定义的类型

at:
http://allenbrowne.com/ser-16.html


-

Allen Browne - 微软MVP。西澳大利亚珀斯

访问用户提示 - http:// allenbrowne .com / tips.html

回复群组,而不是mvps dot org的allenbrowne。


" MLH" < CR ** @ NorthState.net写信息

新闻:1a **************************** **** @ 4ax.com ...
The simplest approach is to pass some extra arguments *into* the function,
and set them in there. The calling routine can then check the value of those
variables afterwards.

A user-defined type is also a good solution for some cases. See:
Multiple return values from a Function - User-defined types
at:
http://allenbrowne.com/ser-16.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthState.netwrote in message
news:1a********************************@4ax.com...

>我想调用一个返回的函数。几个值 - 所有

都与表单上的过程需求相关。我这么做了。
明白FN会返回一个值。


我想知道,这是一个雇用用户定义的好地方输入?


FN将驻留在全局模块中。当被调用时,它确实返回

一个被认为是最重要的值。但是当它正在运行时,

它会计算几个更重要的值,否则在处理时需要在调用函数中重新计算


返回那里。评论?
>I would like to call a function that "returned" several values - all
of which are relevant to the needs of a procedure on a form. I do
understand that FN''s return a single value.

I''m wondering, is this a good place to employ a user-defined Type?

The FN would reside in a global module. When called, it does return
one value considered to be the most important. But while it''s running,
it does calculate several more important values that would otherwise
have to be REcalculated in the calling function when processing
returns there. Comments?


MLH< CR ** @ NorthState.netwrote在

新闻:1a ********* ***********************@4ax.com:
MLH <CR**@NorthState.netwrote in
news:1a********************************@4ax.com:

我想打电话给返回的功能几个值 - 所有

都与表单上的过程需求相关。我这么做了。
明白FN会返回一个值。


我想知道,这是一个雇用用户定义的好地方输入?


FN将驻留在全局模块中。当被调用时,它确实返回

一个被认为是最重要的值。但是当它正在运行时,

它会计算几个更重要的值,否则在处理时需要在调用函数中重新计算


返回那里。评论?
I would like to call a function that "returned" several values - all
of which are relevant to the needs of a procedure on a form. I do
understand that FN''s return a single value.

I''m wondering, is this a good place to employ a user-defined Type?

The FN would reside in a global module. When called, it does return
one value considered to be the most important. But while it''s running,
it does calculate several more important values that would otherwise
have to be REcalculated in the calling function when processing
returns there. Comments?



公共功能MyHeroes(ByVal p1,ByVal p2)As Variant

Dim a(6)As Variant

a(0)= UCase(p1)

a(1)= LCase(p1)

a(2)= StrConv(p1,vbProperCase)

a(3)= UCase(p2)

a(4)= LCase(p2)

a(5)= StrConv(p2,vbProperCase)

MyHeroes = a

结束功能


子测试()

Dim r As Variant

r = MyHeroes(giLbert a HIGHet,harry s Truman)

Debug.Print r(0)

Debug.Print r(1)

Debug.Print r(2)

Debug.Print r(3)

Debug.Print r(4)

Debug.Print r(5)


''GILBERT A HIGHET

''gilbert a highet

''Gilbert A Highet

''HARRY S TRUMAN

''harry s truman

''Harry S Truman


结束分


-

lyle fairfield

Public Function MyHeroes(ByVal p1, ByVal p2) As Variant
Dim a(6) As Variant
a(0) = UCase(p1)
a(1) = LCase(p1)
a(2) = StrConv(p1, vbProperCase)
a(3) = UCase(p2)
a(4) = LCase(p2)
a(5) = StrConv(p2, vbProperCase)
MyHeroes = a
End Function

Sub test()
Dim r As Variant
r = MyHeroes("giLbert a HIGHet", "harry s Truman")
Debug.Print r(0)
Debug.Print r(1)
Debug.Print r(2)
Debug.Print r(3)
Debug.Print r(4)
Debug.Print r(5)

''GILBERT A HIGHET
''gilbert a highet
''Gilbert A Highet
''HARRY S TRUMAN
''harry s truman
''Harry S Truman

End Sub

--
lyle fairfield


谢谢,艾伦。在最简单的情况下,函数执行其工作只需要一个参数
,就没有必要通过FN附加信息
superflous。但是,凭借单一输入,FN可能会在它正在完成工作的同时进行相当多的价值分配

。完成后,它会返回一个

单个且希望对调用过程有用的值。为了达到预期目的,附加输入会做什么?
Thanks, Allen. In the simplest case, where only a single argument is
required for the function to do its job, there would be no need to
pass the FN additional info that would be superflous. But with that
single input, the FN may make a considerable number value assignments
along the way whilst it''s doing its job. When done, it returns a
single and hopefully useful value to the calling procedure. What would
the addtional inputs do to reach the desired end?

>最简单的方法是将一些额外的参数*传递给*功能,
并将它们设置在那里。然后,调用例程可以检查这些变量的值。
>The simplest approach is to pass some extra arguments *into* the function,
and set them in there. The calling routine can then check the value of those
variables afterwards.


这篇关于我想调用一个“返回”的函数。几个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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