Function EstNombreSlashNombre(texte) As Boolean
Dim reg As Object
Set reg = CreateObject("VBScript.RegExp")
With reg
.pattern = "^\d+/\d+$"
.IgnoreCase = True
.Global = False
End With
EstNombreSlashNombre = reg.test(texte)
End Function
Sub Test_EstNombreSlashNombre()
Dim tests As Variant, t As Variant, resultat As Boolean
' Tableau de cas de test
tests = Array("12/5", "3/14", "0/1", "123456/7890", "12 / 5", " 12/5", _
"12/5 ", "abc/12", "12/abc", "12/", "/12", "12-5", "12//5", _
"12/5/7", "12.5/7", "12/7.5", "", " ", "12/ 5", " 12 / 5 ", "0012/0005")
Debug.Print "=== TEST DE LA FONCTION EstNombreSlashNombre ==="
For Each t In tests
resultat = EstNombreSlashNombre(t)
Debug.Print """" & t & """ => " & IIf(resultat, "OK", "NON")
Next t
End Sub