如何在VB中调用函数名引用字符串值的函数 [英] How to call a function with function name reference to a string value in VB

查看:36
本文介绍了如何在VB中调用函数名引用字符串值的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 VB6 上实现这个算法.

I have this algorithm that I want to implement on VB6.

Sub Main()
dim stringVal1 as string, stringVal2 as string
dim getOne as boolean

stringVal1 = "FunctOne"
stringVal2 = "FunctTwo"

if getOne then
    'Call Function with function name assigned to stringVal1 ... how to call the function here?**
else
    'Call Function with function name assigned to stringVal1 ... how to call the function here?**
end if

End Sub


Function FunctOne()
   Msgbox "I'm function one"
End Function

Function FunctTwo()
   Msgbox "I'm function two"
End Function

这可以在 VB6 中完成吗?

Can this be done in VB6?

推荐答案

通常,此类代码模式会指向您的软件设计中的错误.

Generally, such code patterns point to errors in your software design.

在极少数情况下确实需要这样做,CallByName 会完成此操作.

In the rare cases where this is really needed, CallByName accomplishes this.

示例:

Call CallByName(Me, "NameOfFunction", vbMethod, arguments)

这篇关于如何在VB中调用函数名引用字符串值的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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