Comment en peut-il nommé une exception vb ?

Fermé
twix2010 Messages postés 13 Date d'inscription mercredi 23 mars 2011 Statut Membre Dernière intervention 21 décembre 2011 - 3 juin 2011 à 18:08
Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 - 3 juin 2011 à 18:33
Bonjour,

créer une exception nommeé erreurage qui se déclenche lors de la saisie d un age négatif :


CLASSE :

Public Sub New( ByVal n As String, ByVal p As String, ByVal a As Integer)

Me.nom = n
Me.prenom = p

If a <= 0 Then
Throw New Exception(" age n'est pa valide ")
Else
Me.age = a
End If
cpt = cpt + 1
End Sub


MODULE :

Try
listformateur.Add(New formateur(T1.Text, T2.Text, T3.Text, a, T4.Text, T5.Text))
Catch ex As Exception
MsgBox("age négative")
End Try
A voir également:

1 réponse

Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 1 204
3 juin 2011 à 18:33
Bonjour,

Et la question est ?

Pour info : Lire ici

On n'est pas des robots...
0