1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
   | Function IncNom(st As String)
 
Dim stPre As String
Dim stNbre As String
Dim stSuff As String
Dim i As Integer
Dim iMode As Integer ' i =1
 
For i = 1 To Len(st)
  Select Case iMode
    Case 0 'Extrait prefixe
      If Mid(st, i, 1) >= "0" And Mid(st, i, 1) <= 9 Then
        stNbre = Mid(st, i, 1)
        iMode = 1 '.. passe à extraction nombre
      Else
        stPre = stPre & Mid(st, i, 1)
      End If
    Case 1 'Extrait nombre
      If Mid(st, i, 1) >= "0" And Mid(st, i, 1) <= 9 Then
        stNbre = stNbre & Mid(st, i, 1)
 
      Else
        stSuff = Mid(st, i, 1)
        iMode = 2 '.. passe à extraction suffixe
      End If
     Case 2
        stSuff = stSuff & Mid(st, i, 1)
  End Select
 
 
 
Next
 
Debug.Print "<" & stPre & "-" & stNbre & "-" & stSuff & "]"
i = Len(stNbre)
If i > 0 Then
 IncNom = stPre & Right(String(i, "0") & (stNbre + 1), i) & stSuff
 
Else
  IncNom = st
End If
 
End Function | 
Partager