如何在VB 中实现 函数名 用变量来表示
如何在VB 中实现 函数名 用变量来表示
dim fun as string
fun="a1"
function a1()
msgbox "ddd"
end Function
call fun
最后这一句,fun 中存放的就是函数名,这样会出现类型错误,要怎样去转换一下
[解决办法]
用 CallByName,如下示例;
Private Sub Form_Load() Dim res As Long res = CallByName(Me, "func1", VbMethod, 4) MsgBox resEnd SubPublic Function func1(ByVal ii As Integer) As Integer func1 = ii + 2End Function