Results 1 to 2 of 2

Thread: [2005] Dynamicaly call overloaded sub or function

  1. #1

    Thread Starter
    Member mjbrown20's Avatar
    Join Date
    Nov 2006
    Posts
    33

    [2005] Dynamicaly call overloaded sub or function

    As I understand it, overloading allows the appropriate sub/function to be called at run time. Is it possibly to dynammically call a sub based on arguments supplied?

    I am working on a console app that accepts command line arguments. The first argument is my app function to be used. Looking at the example below can I call GetRow and pass an array of args, or do I need to determine the number of arguments supplied and then call based on that?



    Code:
        Sub GetRow(ByVal sheetName As String, ByVal rowNum As Integer, ByVal Blanks As Boolean)
            Console.Write("with blanks")
        End Sub
        Sub GetRow(ByVal sheetName As String, ByVal rowNum As Integer, ByVal sReg As String)
            Console.Write("custom s reg")
        End Sub
        Sub GetRow(ByVal sheetName As String, ByVal rowNum As Integer)
            Console.Write("Normal call")
        End Sub
    "Rightful liberty is unobstructed action according to our will within limits drawn around us by the equal rights of others. I do not add 'within the limits of the law' because law is often but the tyrant's will, and always so when it violates the rights of the individual."
    Thomas Jefferson

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: [2005] Dynamicaly call overloaded sub or function

    what you're looking for is the 'optional' keyword

    vb Code:
    1. Sub GetRow(ByVal sheetName As String, ByVal rowNum As Integer, optional ByVal Blanks As Boolean, optional ByVal sReg As String)

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