Click here to Skip to main content
15,749,281 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,
I have a if statement to check if the button pressed on the messagebox is either "Yes" or no. But it seems to even when I click "No" it executes the "Yes" clause.

Any ideias?

What I have tried:

My code:
MsgBox("Pretende mesmo encerrar a sessão?", vbYesNo, MessageBoxIcon.Information)
       If (DialogResult.Yes) Then
           Dim janela As New frmVerificarColab
           Close()
           janela.Show()

       Else
           MsgBox("Foi escolhido o primeiro carro da lista, se pretender escolher, clique no butão referente á gestão de carros", vbOK, MessageBoxIcon.Information)
       End If
Posted
Updated 24-May-17 4:21am

1 solution

That's because you aren't checking what it returns.
Try:
Dim result = MsgBox("Pretende mesmo encerrar a sessão?", vbYesNo, MessageBoxIcon.Information)
If result = DialogResult.Yes Then
 
Share this answer
 
Comments
Maciej Los 24-May-17 14:35pm    
Oh yeah!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900