end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

Re: Excel VBAで関数名に変数を使う方法

http://www.koikikukan.com/archives/2014/03/28-015555.php
へぇ、他の言語( javascriptjava )でもできるのかな?

'VBAで関数名に変数を使う
Sub Test()
    Dim name As String
    name = 1
    Application.Run "call_" & name
End Sub
 
Sub call_1()
    MsgBox "OK"
End Sub
'関数に引数を追加する
Sub Test()
    Dim name As String
    name = 1
    Dim id As Integer
    id = 100
    Dim value As String
    value = "bar"
    Application.Run "call_" & name, id, value
End Sub
 
Sub call_1(id As Integer, value As String)
    MsgBox id & value
End Sub