-
When you want to create a procedure, like a Function, and you want to be able to call that function for as many objects as you want... example:
Code:
Sub MySub (Str1 as String, Optional Str2 as String, Optional Str3 as String)
How do I get the sub to have more than just two optional string variables?
-
Try this:
Option Explicit
Sub MySub(ByVal NonOptionalString As String, ParamArray OptionalStrings() As Variant)
Dim Count As Long
Print "Non Optional String: " & NonOptionalString
For Count = 0 To UBound(OptionalStrings)
Print "Optional String " & Count + 1 & ": " & OptionalStrings(Count)
Next
End Sub
Private Sub Form_Load()
AutoRedraw = True
Call MySub("Sample", "ABC", "DEF", "GHI", "JKL")
End Sub
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879