Retour sommaire : Syntaxe Visual Basic

Concaténer un libellé avec le libellé précédent

Libelle = "abc"
Libelle &= " suite"

Forme compacte de libellé conditionnel

libelle = If(Teinte1.Length > 0, Teinte1 ,"Aucune teinte")

Tester si une chaîne est vide

if chaine.length = 0 Then
		...
end if

' ou bien 

if string.isnullorwhitespace( chaine ) then
    ...
end if

STARTSWITH: Tester si une chaîne commence par

if chaine.StartsWith("ABC") Then

ENDSWITH: Tester si une chaîne se termine par

if chaine.endsWith("X") then

LEFT: Extraire les 3 premiers caractères

LEFT (chaine, 3)

MID: Extraire une sous-chaine à partir d'une chaine en commencant à "pos_debut" et jusqu'à la fin de la chaine

' pos_debut = 1 pour le premier caractère
Dim sousChaine As String = Mid( Chaine, pos_debut )

MID: Extraire une sous-chaine à partir d'une chaine, en commencant à "pos_debut" et sur un nombre de caractères donné (nb_car)

Dim sousChaine As String = Mid( Chaine, pos_debut, nb_car)

INDEXOF : Rechercher la position d'un caractère dans une chaine, en commençant à un caractère donné

' P**our le premier caractère index_debut=0**
' **Renvoi -1 si pas trouvé**
PosParentheseOuvrante  = ChaineTeintes.indexOf("(", index_debut )