小编Cal*_*chy的帖子

试图用字符串调用Sub - VBA

我有以下代码.

我无法为我的生活弄明白.

我想根据值的不同来调用另一个子i.

例如,如果i = 1它应该调用sale_call1,i = 2它应该调用sale_call2.

Private Sub test_Click()
    Dim i As String
    Dim pro As String

    i = Me.tb1.Value
    pro = "sale_call" + i

    If i = "1" Then
        Call pro
    Else
        Call pro
    End If
End Sub

Sub sale_call1()
    MsgBox "Hello"
End Sub

Sub sale_call2()
    MsgBox "goodbye"
End Sub
Run Code Online (Sandbox Code Playgroud)

string variables vba call

13
推荐指数
1
解决办法
3万
查看次数

标签 统计

call ×1

string ×1

variables ×1

vba ×1