Problème boucle visual basic vb

Résolu/Fermé
Profil bloqué - 10 avril 2011 à 00:19
 Profil bloqué - 10 avril 2011 à 20:39
Bonjour,

J'aimerai empêcher ce timer de tourner en boucle ( code visual basic)

voici le code du timer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If TextBox1.Text.Contains("del") Then

MsgBox("Code dangereux détecté !", MsgBoxStyle.Critical)
Else
MsgBox("Code non dangereux")
End If
Timer2.Start()


aider moi s'il vous plait c'est urgent

A voir également:

2 réponses

lermite222 Messages postés 8702 Date d'inscription dimanche 8 avril 2007 Statut Contributeur Dernière intervention 22 janvier 2020 1 190
10 avril 2011 à 13:55
Bonjour,
Pas facile de comprendre avec les éléments que tu donne, surtout que tu démarre un deuxième timer.
Toute fois je pense te donner une piste...
If TextBox1.Text.Contains("del") Then

    MsgBox "Code dangereux détecté !", MsgBoxStyle.Critical
ElseIf Text <> "" Then
    MsgBox ("Code non dangereux")
    timer1.Enabled = False
    Timer2.Start()
End If
A+
0
Profil bloqué
10 avril 2011 à 14:10
Sa tourne toujours en boucle mais je donne mon code en entier
Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim alltext As String = "", lineoftext As String = ""
OpenFileDialog1.Filter = "All Files | *.*"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then

End If
Try
FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)

Do Until EOF(1)
lineoftext = LineInput(1)
alltext = alltext & lineoftext & vbCrLf
Loop
TextBox1.Text = alltext
Catch
Finally
FileClose()
End Try

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()

End Sub

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If TextBox1.Text.Contains("del") Then

MsgBox("Code dangereux détecté !", MsgBoxStyle.Critical)
ElseIf Text <> "" Then
MsgBox("Code non dangereux")
Timer1.Enabled = False
Timer2.Start()
End If

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

If TextBox1.Text.Contains("Copy C:\") Then

MsgBox("Code dangereux détecté !", MsgBoxStyle.Critical)
Else
MsgBox("Code non dangereux")
End If
Timer2.Stop()

End Sub
End Class
0
Profil bloqué
10 avril 2011 à 20:39
C'est bon j'ai trouver la soluce
au début du timer tapez
timer1.enabled = false
0