Optional (Visual Basic)
Specifies that a procedure argument can be omitted when the procedure is called.
Remarks
You must specify a default value for all optional procedure arguments.
The Optional modifier can be used in these contexts:
The following example defines a procedure that has an optional argument.
Public Function FindMatches(ByRef values As List(Of String),
ByVal searchString As String,
Optional ByVal matchCase As Boolean = False) As List(Of String)
Dim results As IEnumerable(Of String)
If matchCase Then
results = From v In values
Where v.Contains(searchString)
Else
results = From v In values
Where UCase(v).Contains(UCase(searchString))
End If
Return results.ToList()
End Function