Probléme MsgBox avec if

Bonjour le forum, savez-vous pourquoi mon petit programme ne fonctionne pas svp? il provient d'un bouton dans un UserForm, qui au clic ouvre un autre UserForm. Merci.

Private Sub btnCommander_Click()
MsgBox "Voulez-vous commander un nouveau produit?(n'ayant jamais été dans le stock)", vbYesNoCancel + vbInformation, "Nouveau Produit?"
 If MsgBox = vbYes Then
    frmBonCommande.Show
 Else
    MsgBox "Veuillez d'abord sélectionner un produit.", vbOKOnly + vbCritical, "Information"
 End If
End Sub

Cordialement.

Bonjour Minakashi

Ouille effectivement

Voici un code qui devrait mieux aller

Private Sub btnCommander_Click()
If MsgBox("Voulez-vous commander un nouveau produit ? " & VbCr _
    & "(n'ayant jamais été dans le stock)", VbQuestion + vbYesNo, "Nouveau Produit") = vbYes Then
    frmBonCommande.Show
 Else
    MsgBox "Veuillez d'abord sélectionner un produit.", vbOKOnly + vbCritical, "Information"
 End If
End Sub

A+

Merci Bruno, mais je vois qu'il y a une petite erreur de syntaxe :

image

Cordialement

Re,

Code rectifié

A oui super merci Bruno!

Passe un bon après-midi.

Rechercher des sujets similaires à "probleme msgbox"