Results 1 to 13 of 13

Thread: How to call a Procedure by Name.

Threaded View

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    How to call a Procedure by Name.

    I'm sure there's a way to do it and I even think I've done it in the past but I can't find it and an internet search gave me AddressOf and CallByName.

    I use callbyname to recolor my forms at run-time per user preferences.

    So this is what I'm trying to do.

    I'm writing a thing that chooses a random thing to do. Let's say there's 20 choices of random things.

    So I have this:

    Sub Random00
    End Sub

    Sub Random01
    End Sub

    and so on.

    To call it I do this:

    Code:
    Sub DoARandomThing
    Dim nRnd as long
    
    nRnd=int(rnd * 19)
    
    Select Case nRnd
    
        Case 0
    
            Random00
    
        Case 1
    
         Random01
    
    etc.
    What I'd like to do is this:

    Code:
    Sub DoARandomThing
    Dim nRnd as long
    
    nRnd = int(rnd * 19)
    
    CallSubroutineByName "Random" & format(nrnd, "00")
    Last edited by cafeenman; Apr 9th, 2024 at 01:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width