Strings.Trim(String) Méthode

Définition

Retourne une chaîne contenant la copie d'une chaîne spécifiée sans espaces à gauche (LTrim), sans espaces à droite (RTrim) ou sans espaces à droite ni à gauche (Trim).

public:
 static System::String ^ Trim(System::String ^ str);
public static string Trim (string? str);
public static string Trim (string str);
static member Trim : string -> string
Public Function Trim (str As String) As String

Paramètres

str
String

Obligatoire. Toute expression String valide.

Retours

Une chaîne contenant la copie d’une chaîne spécifiée sans espaces à gauche (LTrim), sans espaces à droite (RTrim) ou sans espaces à droite ni à gauche (Trim).

Exemples

Cet exemple utilise la fonction LTrim pour supprimer les espaces à gauche et la fonction RTrim pour supprimer les espaces à droite d'une variable chaîne. Il utilise la fonction Trim pour supprimer les deux types d'espaces.

' Initializes string.
Dim testString As String = "  <-Trim->  "
Dim trimString As String
' Returns "<-Trim->  ".
trimString = LTrim(testString)
' Returns "  <-Trim->".
trimString = RTrim(testString)
' Returns "<-Trim->".
trimString = LTrim(RTrim(testString))
' Using the Trim function alone achieves the same result.
' Returns "<-Trim->".
trimString = Trim(testString)

Remarques

Les LTrimfonctions , RTrimet Trim suppriment les espaces des extrémités des chaînes.

S’applique à

Voir aussi