Results 1 to 9 of 9

Thread: Solved: Check if function has been called as sub

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Solved: Check if function has been called as sub

    Functions can be called as subs, in other words, without the calling code making use of the parameter; in yet other words, not on the right side of an = sign. I feel a function should know if that is the case. For instance, wouldn't it be nice and elegant if we could write the following?
    Function ConcatStrings _
    (ByRef s1 As String, ByVal s2 As String, Optional ByVal sSeparator As String = " ") _
    As String
    ConcatStrings = IIf(s1 = "", s2, s1 & sSeparator & s2)
        If I´mASub Then s1 = ConcatStrings    ' Don't change the parameter unnecessarily.
    End Function
    Where I´mASub is something Boolean (a hidden parameter, or a function) that tells the function whether it has been called as a sub. Is there anything like that?
    Last edited by Bob Phillips; 08-29-2020 at 02:10 AM. Reason: Updated code tags

Posting Permissions

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