Problème boucle visual basic vb

Résolu
Profil bloqué -  
 Profil bloqué -
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

2 réponses

  1. lermite222 Messages postés 9042 Statut Contributeur 1 199
     
    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
    1. Profil bloqué
       
      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
  2. Profil bloqué
     
    C'est bon j'ai trouver la soluce
    au début du timer tapez
    timer1.enabled = false
    0