Share via


Opcional (Visual Basic)

Specifies that a procedure argument can be omitted when the procedure is called.

Comentários

Você deve especificar um valor padrão para todos os argumentos do procedimento de opcional.

The Optional modifier can be used in these contexts:

O exemplo a seguir define um procedimento que tem o argumentoopcional.

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

Consulte também

Outros recursos

Palavras-chave (Visual Basic)