cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 2018
-
11 nov. 2016 à 19:52
cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 2018
-
11 nov. 2016 à 20:58
Bonsoir le forum,
Je souhaite contrôler le contenu de deux variables.
Si var1 ou var2 contiennent ";" et/ou ":" alors True.
Dans mes tests avec Regex, j'ai contatené var1 et var2,
est-ce la bonne méthode ???
Dim testPlanningGlobal As String = "L-VD 0-24"
Dim testPlanningService As String = "L-V 7:30-19"
Dim testPlannings As String = testPlanningGlobal & testPlanningService
If returnMatchPlanning(testPlannings) = True Then
MessageBox.Show(testPlanningGlobal & Environment.NewLine & testPlanningService)
End If
Function returnMatchPlanning(ByVal word As String) As Boolean
Dim patern As String = "[:;]"
For Each m As Match In Regex.Matches(word, patern)
If (m.Success) Then
Return True
End If
Next
Return False
End Function
cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 201826 11 nov. 2016 à 20:58
Merci à NHenry et Whismeril de vos propositions,
J'en conclus que le concaténation des deux variables est préférable au lieu d'utiliser if var1 ... = True And var2 ... = True;
Dim testPlanningGlobal As String = "L-VD 0-24"
Dim testPlanningService As String = "L-V 73019"
Dim testPlannings As String = testPlanningGlobal & testPlanningService
If (testPlannings.Contains(":") Or testPlannings.Contains(";")) = True Then
MessageBox.Show("contient : ou ;")
Else
MessageBox.Show("ne contient ni : ni ;")
End If
11 nov. 2016 à 20:28
même un poil plus court