XL 2013 MsgBox

papy 73 ans

XLDnaute Occasionnel
Bonjour,
Je cherche comment récupérer le clic sur le bouton Oui de 2 MsgBox, dans le code ci-dessous ça renvoi réponse négative.
En vous remerciant.
VB:
 Sub test()    'TEST
     If MsgBox("Question ?", vbYesNo) = vbYes Then
 End If
     If MsgBox("Confirmation !", vbYesNo) = vbYes Then
 End If
     If Rep = vbYes = Rep = vbYes Then
        MsgBox "réponse postive"
    Else
        MsgBox "réponse négative"
  End If
  End Sub
 

Hasco

XLDnaute Barbatruc
Repose en paix
Bonjour,

Deux exemples entre autres possibles:
VB:
Sub test()    'TEST
    If MsgBox("Question ?", vbYesNo) = vbYes And MsgBox("Confirmation !", vbYesNo) = vbYes Then
        MsgBox "réponse postive"
    Else
        MsgBox "réponse négative"
    End If
End Sub

Sub test2()    'TEST
Dim Rep1 As Boolean, Rep2 As Boolean
Rep1 = MsgBox("Question ?", vbYesNo) = vbYes
Rep2 = MsgBox("Confirmation ?", vbYesNo) = vbYes
MsgBox "Réponse " & Choose(1 - (Rep1 And Rep2), "Négative", "Positive")
End Sub

[EDIT
Encore deux autres
VB:
Sub test3()    'TEST
    Dim Rep1 As Boolean
    Rep1 = MsgBox("Question ?", vbYesNo) = vbYes And MsgBox("Confirmation ?", vbYesNo) = vbYes
    MsgBox "Réponse " & Array("Négative", "Positive")(-Rep1)
End Sub
Sub test4()    'TEST
    MsgBox "Réponse " & Array("Négative", "Positive")(-(MsgBox("Question ?", vbYesNo) = vbYes And MsgBox("Confirmation ?", vbYesNo) = vbYes))
End Sub

...arf

cordialement
 
Dernière édition:

Hasco

XLDnaute Barbatruc
Repose en paix
Re,

Encore deux autres et j'arrête:

VB:
Sub test5()
    MsgBox "Réponse " & Array("Négative", "Positive")(-(Questionner() And Confirmer()))
End Sub

Sub Test6()
    MsgBox "Réponse " & Array("Négative", "Positive")(-(Demander("Question") And Demander("Confirmation")))
   
End Sub


Function Questionner(): Questionner = MsgBox("Question", vbYesNo + vbQuestion) = vbYes: End Function
Function Confirmer(): Confirmer = MsgBox("Confirmation", vbYesNo + vbQuestion) = vbYes: End Function
Function Demander(item): Demander = MsgBox(item, vbYesNo + vbQuestion) = vbYes: End Function

Bonne continuation
 

Staple1600

XLDnaute Barbatruc
Bonsoir le fil, papy 73 ans

Juste pour le gag (et pour saluer Roblochon avec ce clin d'oeil) ;)
VB:
Sub test5()
MsgBox "Réponse " & Array("Néga", "Posi")(-(Questionner() And Confirmer())) & "tive"
End Sub

Sub Test6()
MsgBox "Réponse " & Array("Néga", "Posi")(-(Demander("Question") And Demander("Confirmation"))) & "tive"
End Sub


Function Questionner(): Questionner = MsgBox("Question", vbYesNo + vbQuestion) = vbYes: End Function
Function Confirmer(): Confirmer = MsgBox("Confirmation", vbYesNo + vbQuestion) = vbYes: End Function
Function Demander(item): Demander = MsgBox(item, vbYesNo + vbQuestion) = vbYes: End Function
 

Discussions similaires

Statistiques des forums

Discussions
312 488
Messages
2 088 843
Membres
103 972
dernier inscrit
steeter