Bonjour,
Voici un code qui me permet de vérifier si des ComboBox ou TextBox sont vides ou non
If ComboBox_engin = "" Then
Label_engin.ForeColor = RGB(255, 0, 0)
ComboBox_engin.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf ComboBox_engin2 = "" Then
Label_engin.ForeColor = RGB(255, 0, 0)
ComboBox_engin2.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf ComboBox_demandeur = "" Then
Label_demandeur.ForeColor = RGB(255, 0, 0)
ComboBox_demandeur.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf ComboBox_expediteur = "" Then
Label_expediteur.ForeColor = RGB(255, 0, 0)
ComboBox_expediteur.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf ComboBox_destinataire = "" Then
Label_destinataire.ForeColor = RGB(255, 0, 0)
ComboBox_destinataire.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf ComboBox_contact1 = "" Then
Label_contact1.ForeColor = RGB(255, 0, 0)
ComboBox_contact1.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf ComboBox_contact2 = "" Then
Label_contact2.ForeColor = RGB(255, 0, 0)
ComboBox_contact2.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf TextBox_date1 = "" Then
Label_date1.ForeColor = RGB(255, 0, 0)
TextBox_date1.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
ElseIf TextBox_date2 = "" Then
Label_date2.ForeColor = RGB(255, 0, 0)
TextBox_date2.BackColor = RGB(255, 80, 80)
Label_message.Visible = True
Else
Si elles sont vides un label apparait avec un message dedans, et le label et le fond de chaque combobox ou textbox se colorise en rouge.
Le problème avec ce code c'est qu'il les contrôle l'un après l'autre.
Est-il possible de modifier ce code pour contrôler toutes les combobox et textbox d'un coup avec un message unique en msgbox qui préciserait dans ce même message toutes les combobox et textbox vides.
en gros si combobox1, textbox1, textbox2 = vide
msgbox = Les champs suivants sont vides : combobox1, textbox1, textbox2
Si seulement 2 de vide il affichera que les 2, etc.
Merci à vous.