Le titre dit tout
J'ai pas mis de commentaires mais c'est tellement simple ...
Source / Exemple :
Dim div, nbr, nbrdiv As Long
Private Sub Command1_Click()
If Len(Text1.Text) >= 16 Then MsgBox "Le nombre doit comporter 15 chiffres au plus": Exit Sub
nbr = Text1.Text
div = 2
Text2.Text = ""
Text1.Locked = True
Text2.Locked = True
Command1.Enabled = False
Dim TPSstart As Single, TPSstop As Single
TPSstart = Timer
While div <= nbr
While nbr / div = Int(nbr / div)
Text2.Text = Text2.Text & div & " x "
nbr = nbr / div
Wend
DoEvents
Label3.Caption = "En travail : " & Format((nbr / div), "#0.00000000")
div = div + 1
Wend
TPSstop = Format(Timer - TPSstart, "#0.00")
If Text2.Text = Text1.Text & " x " Then
Text2.Text = Text1.Text & " est un nombre premier."
Else
Text2.Text = Mid(Text2.Text, 1, Len(Text2.Text) - 3)
End If
Label3.Caption = ""
Text1.Locked = False
Text2.Locked = False
Command1.Enabled = True
If TPSstop >= 60 Then
If TPSstop / 3600 >= 1 Then
tps = TPSstop \ 3600 & " h, "
TPSstop = TPSstop - (TPSstop \ 3600) * 3600
End If
tps = tps & TPSstop \ 60 & " mins, "
TPSstop = TPSstop - (TPSstop \ 60) * 60
End If
tps = tps & TPSstop & " secs."
MsgBox "Factorisation en facteurs premiers terminée en " & tps
End Sub
Conclusion :
Sur une form mettre Command1 + Label3 + Text1 + Text2
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.