1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
Public Function Extraction(ByVal attente As String) As String
'Je définis les mots à rechercher
Dim motARechercher1 As String = "intervention"
Dim motARechercher2 As String = "alerte"
'Je recherche la position des mots dans le texte (ici à partir de la position 0 et en confondant majuscules et minuscules)
Dim fin1 As Integer = attente.IndexOf(motARechercher1, 0, System.StringComparison.InvariantCultureIgnoreCase)
Dim fin2 As Integer = attente.IndexOf(motARechercher2, 0, System.StringComparison.InvariantCultureIgnoreCase)
'En fonction des valeurs de fin1 et fin2 je retourne la chaîne
If fin1 > -1 Then
Return attente.Substring(0, fin1)
ElseIf fin2 > -1 Then
Return attente.Substring(0, fin2)
Else
Return attente
End If
End Function |
Partager