|
-
Nov 6th, 1999, 04:05 AM
#1
Thread Starter
Hyperactive Member
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?
-
Nov 6th, 1999, 05:21 AM
#2
Guru
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|