After searching, it seems nobody ever needs to pass 3+ arguments to a subroutine.
To my knowledge, VBA subroutines (Which are void) can only have up to 2 parameters (Error when I try 3+), and functions (Which can accept more than 2 parameters) must return a value to whatever called them.
I have been using a little hack to get around this for years, but wondered if there is a better way to pass 3+ arguments to a sub, or to call a void function. Example of what I currently do:
Private Function Foo(str1 as String, Optional str2 as string = "", Optional str3 as string = "") as Boolean
[Do something with parameters, like send an email with programmatic parameters 'to', 'body', and 'subject']
End Function
Public Sub Bar()
Dim dummyVal as Boolean
[Do something]
dummyVal = Foo("CustomerX@mail.com","Report [Today's Date]","Hello [Customer Name]...")
[Do something]
End Sub
This could also be done by using
If Foo(args) Then
End If
These both work, but is probably confusing if someone tries to read my code. Is there a way to pass 3+ arguments to a VBA sub, or to get rid of the "dummyVal" syntax?