Probleme handles

cs_tiki64 Messages postés 2 Date d'inscription vendredi 1 décembre 2000 Statut Membre Dernière intervention 26 mai 2008 - 26 mai 2008 à 03:10
Kevin.Ory Messages postés 840 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 7 janvier 2009 - 26 mai 2008 à 16:42
Bonjour,
Dans une application sur visual basic 2005,  j'ai une erreur:

"La clause Handles requiert une variable WithEvents définies dans le type conteneur ou l'un de ses types de base. "

L'erreur est sur cette ligne : Sub PictureBox1Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox1.Click

Il faut donc que je déclare une variable WithEvents mais je ne sais pas où.

Merci de votre aide

3 réponses

Kevin.Ory Messages postés 840 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 7 janvier 2009 11
26 mai 2008 à 03:45
Salut,

C'est ta PictureBox1 que tu dois déclarer avec WithEvents
0
cs_tiki64 Messages postés 2 Date d'inscription vendredi 1 décembre 2000 Statut Membre Dernière intervention 26 mai 2008
26 mai 2008 à 03:51
j'ai une erreur à chaque "handles"
Où est ce que je dois déclarer mes picturebox svp? (je suis vraiment nul en objet)

Merci

Voici le code:
Imports System.Math
Imports System.DateTime
Imports System.Drawing.Color

Public Partial Class MainForm
    
    Dim ToolTip1 As New ToolTip
    Dim A, B, C, D, E As Decimal  'Variable alcool et total    Dim K As Decimal 'Homme 0.7 / Femme 0.6
    Dim M As Integer  'Poids
    Dim T, R As Decimal  'T: Taux, R:  Récup
    
    Public Sub New()
        
        Me.InitializeComponent()
        'Affichage des infos sur les images
        ToolTip1.SetToolTip(Me.PictureBox1, "Calculer le taux d'alcoolémie")
        ToolTip1.SetToolTip(Me.PictureBox2, "Ajouter une bière")
        ToolTip1.SetToolTip(Me.PictureBox3, "Ajouter un verre de vin")
        ToolTip1.SetToolTip(Me.PictureBox4, "Ajouter un verre de vin")
        ToolTip1.SetToolTip(Me.PictureBox5, "Ajouter une dose d'alcool fort")
        ToolTip1.SetToolTip(Me.PictureBox6, "Ajouter une dose d'alcool doux")
        ToolTip1.SetToolTip(Me.PictureBox7, "Ajouter une dose d'alcool fort")
        ToolTip1.SetToolTip(Me.PictureBox10, "Afficher l'aide")
        K = 0.7
        M = 80
        
    End Sub
    
    Sub PictureBox1Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox1.Click

        On Error Resume Next

        Alcoolemie()

    End Sub
    
    Sub Alcoolemie
        
        On Error Resume Next
        
        E = A + B + C + D  'Total des consommation
        TextBox5.Text = E        If radioButton1.Checked True Then K 0.7  'Homme        If radioButton2.Checked True Then K 0.6  'Femme
        
        TextBox6.Text = (E * 0.8) / (K * M)  'Formule alcoolemie
        T = TextBox6.Text
        Label14.Text = Math.Round(T, 2)  'Arrondi 2 chiffres après la virgule
        
        R = Label14.Text - 0.5
        TextBox7.Text = R / 0.15 * 60  'Alcool à évacuer
        If TextBox7.Text < 0 Then TextBox7.Text = 0
        
        Dim Heure As String
        Heure = Int(TextBox7.Text / 60) & " heure(s) et " & TextBox7.Text Mod 60 & " minute(s)"
        Label17.Text = Heure  'Affichage du nombre d'heure(s) pour récupérer
        
        If TextBox7.Text < 0.5 Then
            'Affichage du texte en bleu ou en rouge
            Label14.ForeColor = System.Drawing.Color.SteelBlue
            Label15.ForeColor = System.Drawing.Color.SteelBlue
            Label17.Visible = False
        Else
            Label14.ForeColor = System.Drawing.Color.Firebrick
            Label15.ForeColor = System.Drawing.Color.Firebrick
            Label17.Visible = True
        End If
        
    End Sub
    
    Sub NumericUpDown4ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown4.ValueChanged

        On Error Resume Next

        TextBox1.Text = (numericUpDown4.Value * 250) * (numericUpDown7.Value / 100)
        A = TextBox1.Text  'valeur de 25cl de bière

    End Sub
    
    Sub NumericUpDown7ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown7.ValueChanged

        On Error Resume Next

        textBox1.Text = (numericUpDown4.Value * 250) * (numericUpDown7.Value / 100)
        A = textBox1.Text

    End Sub
    
    Sub NumericUpDown6ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown6.ValueChanged

        On Error Resume Next

        TextBox2.Text = (numericUpDown6.Value * 20) * (numericUpDown5.Value / 100)
        B = TextBox2.Text

    End Sub
    
    Sub NumericUpDown5ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown5.ValueChanged

        On Error Resume Next

        textBox2.Text = (numericUpDown6.Value * 20) * (numericUpDown5.Value / 100)
        B = textBox2.Text

    End Sub
    
    Sub NumericUpDown1ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown1.ValueChanged

        On Error Resume Next

        M = numericUpDown1.Value

    End Sub
    
    Sub Timer1Tick(ByVal sender As Object, ByVal e As EventArgs) Handles timer1.Tick

        On Error Resume Next

        label2.Text = Now.ToLongTimeString  'Affichage de l'heure

    End Sub
    
    Sub NumericUpDown9ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown9.ValueChanged

        On Error Resume Next

        textBox3.Text = (numericUpDown9.Value * 100) * (numericUpDown8.Value / 100)
        C = textBox3.Text

    End Sub
    
    Sub NumericUpDown8ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown8.ValueChanged

        On Error Resume Next

        TextBox3.Text = (numericUpDown9.Value * 100) * (numericUpDown8.Value / 100)
        C = TextBox3.Text

    End Sub
    
    Sub NumericUpDown11ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown11.ValueChanged

        On Error Resume Next

        TextBox4.Text = (numericUpDown11.Value * 60) * (numericUpDown10.Value / 100)
        D = TextBox4.Text

    End Sub
    
    Sub NumericUpDown10ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles numericUpDown10.ValueChanged

        On Error Resume Next

        textBox4.Text = (numericUpDown11.Value * 60) * (numericUpDown10.Value / 100)
        D = textBox4.Text

    End Sub
    
    Sub PictureBox2Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox2.Click

        On Error Resume Next

        numericUpDown4.Value = numericUpDown4.Value + 1

    End Sub
    
    Sub PictureBox3Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox3.Click

        On Error Resume Next

        numericUpDown9.Value = numericUpDown9.Value + 1

    End Sub
    
    Sub PictureBox4Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox4.Click

        On Error Resume Next

        numericUpDown9.Value = numericUpDown9.Value + 1

    End Sub
    
    Sub PictureBox5Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox5.Click

        On Error Resume Next

        numericUpDown6.Value = numericUpDown6.Value + 1

    End Sub
    
    Sub PictureBox7Click(ByVal sender As Object, ByVal e As EventArgs)

        On Error Resume Next

        numericUpDown6.Value = numericUpDown6.Value + 1

    End Sub
    
    Sub PictureBox6Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox6.Click

        On Error Resume Next

        numericUpDown11.Value = numericUpDown11.Value + 1

    End Sub
    
    Sub PictureBox10Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox10.Click

        PictureBox8.Visible = True  'Affichage de l'aide

    End Sub
    
    Sub PictureBox8Click(ByVal sender As Object, ByVal e As EventArgs) Handles pictureBox8.Click

        pictureBox8.Visible = False  'Masquer l'aide

    End Sub
    
    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub
End Class
0
Kevin.Ory Messages postés 840 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 7 janvier 2009 11
26 mai 2008 à 16:42
Si tu as insérer ton PictureBox sur ta Form par l'IDE, il devrait déjà y avoir le WithEvents

Fais bouton droit sur ton "Me.InitializeComponent()" et "Afficher la déclaration" (ou un truc du genre). Ceci t'amènera dans une autre partie de ta classe qui est (normalement) utlisé que par le designer. Tu y trouvera la déclaration de ta PictureBox....

Je commence à douter que le problème vient de là, puisque apparement tu as utlisé l'IDE pour ajouter la PictureBox à ta Form...
0
Rejoignez-nous