Appliquation qui se ferme tout seul !

carean - 20 janv. 2013 à 12:54
 carean - 20 janv. 2013 à 18:41
Bonjour , hier j'ai appris le vb. J'ai commencer par vouloir faire un bloc note , alors j'ai commencer en début de soirer et je l'ai fini ce matin , je le compile et la quand je le lance il marche et au bout de environ 10-15seconde il se ferme ne sachant pas d'ou vient le probleme je regardit plusieur de code a la recherche d'heure . Aujourd'hui n'ayant pas trouver le probleme je vous pose la question. Mon blo note est en vb10.Je vous met la form1
Public Class Form1





    Private Sub NouveauToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NouveauToolStripMenuItem.Click
        If Dialog1.ShowDialog() And Windows.Forms.DialogResult.OK Then
            RichTextBox2.Clear()
        Else
            Dialog1.Close()
            Dim saveFile1 As New SaveFileDialog()
            saveFile1.DefaultExt = "*.txt"
            saveFile1.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf|Tous Les Fichiers(*.*)|*.*"
            If (saveFile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
                And (saveFile1.FileName.Length > 0) Then
                RichTextBox2.SaveFile(saveFile1.FileName)
            End If
        End If

    End Sub

    Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click
        Try
            Dim ofp As OpenFileDialog = New OpenFileDialog
            ofp.Title = "Ouvrir ..."
            ofp.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf|Tous Les Fichiers(*.*)|*.*"
            If ofp.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                RichTextBox2.LoadFile(ofp.FileName)
            End If
        Catch ex As Exception : End Try
    End Sub

    Private Sub SauvegarderToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrezsousToolStripMenuItem.Click
        Try
            Dim dlg As SaveFileDialog = New SaveFileDialog
            dlg.Title = "Enregistrer"
            dlg.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf|Tous Les Fichiers(*.*)|*.*"
            If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                RichTextBox1.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText)
            End If
        Catch ex As Exception : End Try
    End Sub

    Private Sub AnnulerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnnulerToolStripMenuItem.Click
        RichTextBox2.Undo()
    End Sub

    Private Sub RefaireToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefaireToolStripMenuItem.Click
        RichTextBox2.Redo()
    End Sub

    Private Sub CouperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CouperToolStripMenuItem.Click
        RichTextBox2.Cut()
    End Sub

    Private Sub CopierToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopierToolStripMenuItem.Click
        RichTextBox2.Copy()
    End Sub

    Private Sub CollerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CollerToolStripMenuItem.Click
        RichTextBox2.Paste()
    End Sub

    Private Sub SélectionnerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SéllectionnerToolStripMenuItem.Click
        RichTextBox2.SelectAll()
    End Sub

    Private Sub EffacerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EffacerToolStripMenuItem.Click
        RichTextBox2.Clear()
    End Sub

    Private Sub PoliceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PoliceToolStripMenuItem.Click
        Try
            Dim tito As FontDialog = New FontDialog
            tito.Font = RichTextBox2.Font
            If tito.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                RichTextBox2.Font = tito.Font
            End If
        Catch ex As Exception : End Try
    End Sub

    Private Sub CouleurToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CouleursToolStripMenuItem.Click
        Try
            Dim clr As ColorDialog = New ColorDialog
            clr.Color = RichTextBox2.ForeColor()
            If clr.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                RichTextBox2.ForeColor = clr.Color
            End If
        Catch ex As Exception : End Try

    End Sub

    Private Sub GButton1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GButton1.Click
        Dim x As Integer
        x = MsgBox("Voulez vous quitter", MsgBoxStyle.YesNo, "Confirmation")
        If x = MsgBoxResult.Yes Then
            End
        End If
    End Sub
    Private Sub GTheme1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Private Sub GButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Private Sub GButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Private Sub RichTextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)

    End Sub
    Private Sub FichierToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub RichTextBox3_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub


    Private Sub RechercherToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RechercherToolStripMenuItem.Click
        Dim ch As String
        ch = InputBox("donner le mot à chercher", " recherche ")
        RichTextBox2.Find(ch)
    End Sub

    Private Sub GButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub RichTextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox2.KeyPress
        ToolStripLabel4.Text = Len(RichTextBox2.Text) & " caractères"
        If e.KeyChar = Chr(13) Then
            ToolStripTextBox1.Text = ToolStripTextBox1.Text + 1
        End If
    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = TimeOfDay
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ToolStripButton1_ButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        RichTextBox2.SelectionAlignment = HorizontalAlignment.Right
    End Sub


    Private Sub CouleurDeFondToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CouleursDeFondToolStripMenuItem.Click
        ColorDialog1.ShowDialog()
        RichTextBox2.BackColor = ColorDialog1.Color

    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        RichTextBox2.SelectionAlignment = HorizontalAlignment.Left

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        RichTextBox2.SelectionAlignment = HorizontalAlignment.Center
    End Sub

    Private Sub PucesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PucesToolStripMenuItem.Click
        RichTextBox2.SelectionBullet = True
    End Sub

    Private Sub Label1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

   
    Private Sub ToolStripLabel5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

        Dim Lignes As Integer, i As Integer
        For i = 1 To Len(RichTextBox2.Text)
            If Mid(RichTextBox2.Text, i, 1) vbLf Then Lignes Lignes + 1
        Next i
        MsgBox(Lignes)
    End Sub

    Private Sub ToolStripTextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTextBox1.Click

       

    End Sub

    Private Sub GButton2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GButton2.Click
        Form2.Show()
    End Sub

    Private Sub GButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GButton3.Click
        Form4.Show()
    End Sub

    Private Sub RichTextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox2.TextChanged
        Me.TopMost = True
    End Sub
End Class




Merci de bien vouloir m'aider.

6 réponses

ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
20 janv. 2013 à 13:51
BONJOUR?
Je n'ai pu suivre>.$Et pour cause : ce n'est certes pas du :
Forum > Visual Basic 6

J'ai donc perdu mon temps à ouvrir et luire.


________________________
Réponse exacte ? => "REPONSE ACCEPTEE" facilitera les recherches.
Pas d'aide en ligne installée ? => ne comptez pas sur moi pour simplement répéter son contenu. Je n'interviendrai que si nécessité de la compléter.
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
20 janv. 2013 à 14:00
DXeux choses m'interpellent toutefois :
1)
 If x = MsgBoxResult.Yes Then
   End
End If

ne me parait pas être une sortie propre...
2) :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
End Sub

sans que l'on ait la moindre idée de ce que contient l'évènement Tick de ce Timer1 !!! (j'ai interrogé ma boule de cristal.. . elle n'a su me répondre avec précision, mais m'a quand-même soufflé qu'il contenait une instruction de sortie après un certain laps de temps ...! ...:)
________________________
Réponse exacte ? => "REPONSE ACCEPTEE" facilitera les recherches.
Pas d'aide en ligne installée ? => ne comptez pas sur moi pour simplement répéter son contenu. Je n'interviendrai que si nécessité de la compléter.
0
je vais regarder si ta boule de cristal a raison ^^ je suis desolé de l'avoir mis dans la mauvaise section :'(
 If x = MsgBoxResult.Yes Then
   End
End If

j'utilise un theme de visual basic qui suprime les 3 boutons (agrandir - retrecir - suprimer) donc j'ai dut ajouter des bouton moi meme . et ce bouton demande si oui ou non il veut fermer apres avoir cliquer sur le bouton.

Pour le timer il me semble que ses l'endroit ou j'ai mis l'heure , je vais verifier.
Merci encore de ton aide
0
j'ai verifier pour le timer .
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = TimeOfDay
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub

cela me semble bon, le timer ce lance en meme temps que la form1 qui est la premier form de mon appliquation et le label1 affiche l'heure recu.
Ce qui veut dire je sais toujours pas d'ou vien le probleme :'(
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Utilisateur anonyme
20 janv. 2013 à 18:12
Bonjour,

Exécute ton application au pas à pas. Tu devrais voir quelle ligne provoque la fermeture.
0
cbon j'ai trouver le probleme , je sais pas pourquoi met il sufisait de rallumer le pc et le logiciel marcher corectement il devait peut etre se mettre a jour ou quelque chose comme sa , en tout cas j'ai passer toute l'aprem a chercher alors qu'il fallait redemarer ...><'
0
Rejoignez-nous