hello, I have in my procedure this code:

1. Selelect Case  Count
2.  Case 1
3.    Call MySub1()
4.  Case 2
5.    Call MySub2()
6.  Case 3
7.    Call MySub3()
8.  '...
9.  Case N
10.   Call MySubN()
11.End Select

But using an array:

1. Dim ArrMySubs(N) as string
2. ArrMySubs(1)="MySub1"
3. ArrMySubs(2)="MySub2"
4. ArrMySubs(3)="MySub3"
5. '...
6. ArrMySubs(N)="MySubN"

how can I call ArrMySubs(N) using vbscript?

Hi

You can use GetRef to do this, for example:

Dim arrMySubs(3)

arrMySubs(1) = "Sub1"
arrMySubs(2) = "Sub2"
arrMySubs(3) = "Sub3"

Dim count
count = 3

Dim f   'Function variable
Set f = GetRef(arrMySubs(count))

f

Sub Sub1()
    MsgBox "Hello from Sub1"
End Sub

Sub Sub21()
    MsgBox "Hello from Sub2"
End Sub

Sub Sub3()
    MsgBox "Hello from Sub3"
End Sub

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.