Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7186773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:42:14+00:00 2026-05-28T18:42:14+00:00

I’m working with a third-party library interfacing to an old database system. There’s a

  • 0

I’m working with a third-party library interfacing to an old database system. There’s a method – CallProg that calls a “stored procedure” (for lack of a better translation – any Pick users in the crowd?). However, instead of doing something like this:

Public Sub CallProg(ProgName, ParamArray ProgArgs() As String)
    ...
End Sub

or even this:

Public Sub CallProg(ProgName, Optional Arg1 As String, Optional Arg2 As String ... Optional Arg20 As String)

They did this:

Public Sub CallProg(ProgName)
Public Sub CallProg(ProgName, Arg1 As String)
Public Sub CallProg(ProgName, Arg1 As String, Arg2 As String)
Public Sub CallProg(ProgName, Arg1 As String, Arg2 As String, Arg3 As String)
...
Public Sub CallProg(ProgName, Arg1 As String, ... Arg20 As String)

I’m writing an abstraction class to handle logging in, setting the environment, etc., so it can be used as a generic “helper” class in a number of other projects. Is there any way to wrap the CallProg sub that doesn’t involve 20 overloads?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:42:15+00:00Added an answer on May 28, 2026 at 6:42 pm

    This is a very quick idea of how to do it using reflection. I’m not sure if its the best way but it should work…

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        CallProg("ProgName", {"testArg1", "TestArg2"})
    
    End Sub
    
    Private Sub CallProg(ByVal ProgName As String, ByVal Params As IEnumerable(Of String))
    
        Dim testClass As New Test1
    
        Dim methodTypes As List(Of Type) =
            Params.Select(Function(x) GetType(String)).ToList
    
        methodTypes.Add(GetType(String))
    
        Dim methodToBeCalled As Reflection.MethodInfo =
            testClass.GetType.GetMethod("CallProg",
                                        System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.Public,
                                        Type.DefaultBinder,
                                        methodTypes.ToArray,
                                        Nothing)
    
    
        Dim paramsToPass As New List(Of String)
    
        paramsToPass.Add(ProgName)
        paramsToPass.AddRange(Params)
    
        methodToBeCalled.Invoke(testClass, paramsToPass.ToArray)
    
    End Sub
    

    End Class

    Public Class Test1

    Public Sub CallProg(ByVal ProgName As String)
        Debug.WriteLine("Sub0 called")
    End Sub
    
    Public Sub CallProg(ByVal ProgName As String, ByVal Arg1 As String)
        Debug.WriteLine("Sub1 called")
    End Sub
    
    Public Sub CallProg(ByVal ProgName As String, ByVal Arg1 As String, ByVal Arg2 As String)
        Debug.WriteLine("Sub2 called")
    End Sub
    
    Public Sub CallProg(ByVal ProgName As String, ByVal Arg1 As String, ByVal Arg2 As String, ByVal Arg3 As String)
        Debug.WriteLine("Sub3 called")
    End Sub
    

    End Class

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I have a reasonable size flat file database of text documents mostly saved in
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.