Private Sub CommandButton1_Click() Dim toto As String toto = "Test-0000A25125" MsgBox toto & " ====>>" & atraiter(toto) toto = "Test-25125A" MsgBox toto & " ====>>" & atraiter(toto) End Sub Private Function atraiter(c As String) As String atraiter = c pos = InStr(atraiter, "-") If pos = 0 Then Exit Function atraiter = Mid(atraiter, pos + 1) While Mid(atraiter, 1, 1) = "0" atraiter = Mid(atraiter, 2) Wend atraiter = Left(c, pos) & atraiter End Function
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub ess() Text = "machin-0000025125 " pos = InStr(1, Text, "-") MsgBox Mid$(Text, 1, pos - 1) & Str$(Val(Mid$(Text, pos, Len(Text)))) End Sub
Function us(c As String) As String Do c = Replace(c, "-0", "-") Loop Until InStr(1, c, "-0") = 0 us = c End Function
Private Sub Command1_Click() Dim toto_a_la_us As String toto_a_la_us = "Test-0000A25125" MsgBox toto_a_la_us & " ====>>" & us(toto_a_la_us) toto_a_la_us = "Test-25125A" MsgBox toto_a_la_us & " ====>>" & us(toto_a_la_us) End Sub
Function us(c As String) As String us = Replace(c, "-0", "-") If InStr(1, us, "-0") <> 0 Then us = us(us) End Function