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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| Option Explicit
Dim StrMot As String
Dim MinChiFre As Integer
Private Sub Form_Load()
Me.Height = 1815: Me.Width = 4320
Command1.Move 120, 120, 1575, 255: Command1.Caption = "Go"
Text1.Move 120, 480, 3795, 555: Text1.Text = ""
StrMot = "cdsljldjqhskdhsqjgdjqsgdjhgfsqhgdfqshqsf62726Y9802UYGHKJDSHKJDSGJ72368T32GYISKJH093UFODJSHKF0ZE9U3YHFUID803RFHDJKHFBKDJhgKJFHDGKJFDJKSH3987R4963YA9YUHEKGF79Z439764376Y"
Timer1.Enabled = False
Timer1.Interval = 1000 ' 1 Sc
MinChiFre = 9
End Sub
'*********************** fonction d'analyse si numerique (True/false) *********************************************
Private Function stringchainedechiffreestegala9(StrSounmis As String) As Boolean
Dim T As Long
Dim Correction As String
For T = 1 To (Len(StrSounmis) - MinChiFre) + 1
If IsNumeric(Mid$(StrSounmis, T, MinChiFre)) Then
Correction = Mid$(StrSounmis, T, MinChiFre)
Correction = Replace(Correction, " ", "")
If Len(Correction) = Len(Mid$(StrSounmis, T, MinChiFre)) Then
'MsgBox Mid$(StrSounmis, T, MinChiFre) & vbNewLine _
'& "Position : " & T & " à " & ((T + MinChiFre) - 1)
stringchainedechiffreestegala9 = True
Exit For
End If
End If
Next T
End Function
'******************************************************************************************************************
'------------------ Evenement sur detection d'une entrée utilisateur -----------
Private Sub Text1_Change()
If Len(Text1.Text) >= MinChiFre Then
If stringchainedechiffreestegala9(Text1.Text) Then
MsgBox "condition " & MinChiFre & " chiffre atteinte", vbInformation, ""
End If
End If
End Sub
'-------------------------------------------------------------------------------
'------------------ Evenement sur detection periodique -------------------------
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled = False Then
Command1.Caption = "Go"
Else
Command1.Caption = "Arreter"
End If
End Sub
Private Sub Timer1_Timer()
If stringchainedechiffreestegala9(StrMot) Then
Timer1.Enabled = False ' mes fin à la detection
MsgBox "condition " & MinChiFre & " chiffre atteinte", vbInformation, ""
End If
End Sub
'------------------------------------------------------------------------------- |
Partager