Results 1 to 2 of 2

Thread: Using functions directly [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    1

    Resolved Using functions directly [Resolved]

    I've got a function that walks through all files on my harddrive. Depending on the user's settings it has to do a specific operation on those files.

    Incuding the code for all of these operations in the function that walks through my files would mess-up my code.

    Now I used select case to find out which function to use. When I add a new function, I always have to add it in the Walkthroughfiles function.

    Isn't there an easier way to do this?

    Private Function Walkthroughfiles(option as string)

    'Select next file...

    Select Case option
    Case "One": a = One
    Case "Two": a = Two

    'Loop...
    End Select

    msgbox a
    End Function

    Public Function One()
    'Some code
    One = "operation 1 completed successfully)
    End Function

    Public Function Two()
    'Some code
    Two = "operation 2 completed successfully)
    End Function
    Last edited by jacco1; May 27th, 2005 at 10:09 AM. Reason: Resolved; thanks

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Using functions directly

    You could use the CallByName built-in function, and hold all the functions in a module, and call like:

    VB Code:
    1. CallByName "ModuleName." & strFuncName

    Search your MSDN for CallByName for more info.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

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