我想调用一个“返回”的函数。几个值

编程入门 行业动态 更新时间:2024-10-20 15:52:53
本文介绍了我想调用一个“返回”的函数。几个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想调用一个返回的函数。几个值 - 所有 都与表单上的过程需求相关。我这么做了。明白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: allenbrowne/ser-16.html - Allen Browne - 微软MVP。西澳大利亚珀斯 访问用户提示 - http:// allenbrowne / tips.html 回复群组,而不是mvps dot org的allenbrowne。 " MLH" < CR ** @ NorthState写信息 新闻:1a **************************** **** @ 4ax ... 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: allenbrowne/ser-16.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - allenbrowne/tips.html Reply to group, rather than allenbrowne at mvps dot org. "MLH" <CR**@NorthStatewrote in message news:1a********************************@4ax... >我想调用一个返回的函数。几个值 - 所有 都与表单上的过程需求相关。我这么做了。明白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 ** @ NorthStatewrote在 新闻:1a ********* ***********************@4ax: MLH <CR**@NorthStatewrote in news:1a********************************@4ax: 我想打电话给返回的功能几个值 - 所有 都与表单上的过程需求相关。我这么做了。明白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 thosevariables afterwards.

更多推荐

我想调用一个“返回”的函数。几个值

本文发布于:2023-10-31 06:10:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545247.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我想   几个   函数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!