RE RYU
pas de mess technique par MP
pour ton problème
il y a plusieurs techniques
en voici quelques unes le nom des fonctions est explicite
methode avec la fonction replace de vbscript regexp
1 2 3 4 5 6 7 8
| Sub test()
Dim txt As String, Txt2 As String
txt = UCase("TOTO_01_REL.Txt")
MsgBox chiffre_seulement(txt)
End Sub
Function chiffre_seulement(txt As String)
With CreateObject("VBScript.RegExp"): .Global = True: .Pattern = "[a-z-A-Z-_?.]": chiffre_seulement = .Replace(txt, ""): End With
End Function |
methode avec la fonction execute de vbscript.regexp
1 2 3 4 5 6 7 8 9
|
Sub test2()
Dim txt As String, Txt2 As String
txt = UCase("TOTO_01_REL.Txt")
MsgBox chiffre_seulementbis(txt)
End Sub
Function chiffre_seulementbis(txt As String)
With CreateObject("VBScript.RegExp"): .Global = True: .Pattern = "(\d+)": Set Matches = .Execute(txt): chiffre_seulementbis = Matches(0): End With
End Function |
apres si ta chaine est totalement numeric ou string c'est simple avec VBA
if isnumeric(chaine) then ......' si elle est numerique ??.
apres si tu veut savoir avec VBA si il elle est string et si il y a quand meme des numériques
if isnumeric(chaine) =false and chaine like "[0-9]" then msgbox "cette chaine n'est pas numerique mais comporte des chiffre "
voila t'a tout
Partager