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
| Private Type nume
millions As Integer
centmilliers As Integer
dixmilliers As Integer
milliers As Integer
centaines As Integer
dizaines As Integer
unites As Integer
End Type
Private Sub Command1_Click()
Dim toto As Long
toto = 1124791
MsgBox toto & " ===>>> " & vbCrLf & titi(toto).unites & " unités " & vbCrLf & _
titi(toto).dizaines & " dizaines " & vbCrLf & _
titi(toto).centaines & " centaines " & vbCrLf & _
titi(toto).milliers & " milliers " & vbCrLf & _
titi(toto).dixmilliers & " dizaines de milliers " & vbCrLf & _
titi(toto).centmilliers & " centaines de milliers " & vbCrLf & _
titi(toto).millions & " millions " & vbCrLf
End Sub
Private Function titi(ByVal nb As Long) As nume
dim n as string, pos as integer
n = CStr(nb)
pos = Len(n)
titi.unites = Mid(n, pos, 1): pos = pos - 1
If pos Then titi.dizaines = Mid(n, pos, 1): pos = pos - 1
If pos Then titi.centaines = Mid(n, pos, 1): pos = pos - 1
If pos Then titi.milliers = Mid(n, pos, 1): pos = pos - 1
If pos Then titi.dixmilliers = Mid(n, pos, 1): pos = pos - 1
If pos Then titi.centmilliers = Mid(n, pos, 1): pos = pos - 1
If pos Then titi.millions = Mid(n, pos, 1): pos = pos - 1
End Function |
Partager