• Passing parameters

    Author
    Topic
    #458498

    Hi

    Got an observation that’s puzzling me – looking for an explanation…

    I’m in the middle of writing an add-in that handles connections etc. to a DB-layer.
    Main part of my code is encapsulated into a class module ‘clsDB’.

    To have the functions visible from outside the ad-in, I’ve added a ‘module-layer’ with ‘public subs’, s that calls to the clsDB goes through the module layer,

    …but – if I’m not passing parameters to the sub – it is visible in ‘Tools’ -> ‘Macro’ -> ‘Macros’ (example below)

    Public Sub GetShareHolders()
    Dim oDB As clsDB
    Set oDB = New clsDB
    oDB.Connect
    oDB.GetMajorShareholders oDB
    Set oDB = Nothing
    End Sub

    …and – if I do pass parameters – it is no longer visible… – wondering why???

    Public Sub GetShareHolders(ByVal strSource As String, ByVal strTicker As String)
    Dim oDB As clsDB
    Set oDB = New clsDB
    oDB.Connect
    oDB.GetMajorShareholders oDB, strSource, strTicker
    Set oDB = Nothing
    End Sub

    Viewing 1 reply thread
    Author
    Replies
    • #1153108

      A macro by definition is a public procedure (sub) without arguments in a standard module.

      It wouldn’t make sense to list procedures that have arguments in Tools | Macro | Macros because they can’t be run by themselves – you have to specify the argument(s) in order to run them.

    • #1153120

      You can, incidentally, still run the macros from the dialog, you just have to manually type in the name and parameters.

    Viewing 1 reply thread
    Reply To: Passing parameters

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: