0

can you please help me in my code

MsgBox "Are you sure you want to Logout?", vbYesNo, "Confirmation"

If vbYes Then
    Unload Me
    frmAuthentication.Show
    End If

how can i have 2 choices example i want vb no and just stay with my form help me..

6
Contributors
20
Replies
36
Views
2 Years
Discussion Span
Last Post by Nutster
Featured Replies
  • You need to use the same variable for the return value as well as the test. You used `responce` to save the result but your test uses `reply`. Another possibility would be If MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation") = vbYes Then Unload Me frmAuthentication.Show else exit … Read More

0

Can you reword "how can i have 2 choices example i want vb no and just stay with my form help me.."

It is not clear what you need.

Thanks

0

ok sir for example

If vbYes Then
    Unload Me
    frmAuthentication.Show
ElseIf vbno then
    Unload Me
(EXAMPLE I JUST WANT TO STAY WITH THE FORM)

end if 

Like that sir but its not correct thanks :D

0

the msg box is this

Edited by Christian_4: jejeje

Attachments jaja.jpg 14.83 KB
0

but if i click yes it will log out and even i pick no it still log out :(

0

No need for an Else statement since that does nothing.

Dim reply As Integer = MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation")

If reply = vbYes Then
    Unload Me
    frmAuthentication.Show
End If
0
Private Sub cmdLogout_Click()
Dim reply As Integer = MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation")
If reply = vbYes Then
Unload Me
frmAuthentication.Show
End If
End Sub

Here sir! ty

0

Looks oks to me. Can you zip and send me the whole solution?

Message me for my email if you want to send it.

0

In vb6 you can't use declaration= dadada but you need to seperate these.

Private Sub cmdLogout_Click()
Dim reply As String
reply = MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation")
If reply = vbYes Then
Unload Form1
frmAuthentication.Show
End Sub

This makes me always question is it vb6 or vb.net?

0
Dim responce As Integer 
responce = MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation")
If reply = vbYes Then
    Unload Me
    frmAuthentication.Show
else
    exit sub
End If

Edited by Reverend Jim: Already answered, and your code won't work.

1

You need to use the same variable for the return value as well as the test. You used responce to save the result but your test uses reply. Another possibility would be

If MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation") = vbYes Then
    Unload Me
    frmAuthentication.Show
else
    exit sub
End If

Edited by Reverend Jim

Votes + Comments
That is the version I use.
2

thanks reverend jim my mistake thanks for pointing out i use response in what ever code i write for myself so in the description they were using reply and i used description in a mistake

Votes + Comments
Setting Option Explicit at the beginning of the file can help catch this kind of thing.
Yeah. I've done that.
0

Another way of handling this is with a Select block:

Select Case MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation")
Case vbYes
    frmAuthenticaion.Show
    Unload Me
Case vbNo
    Exit Sub
End Select

Using a Select block gives you more flexibility for when you are using an option that gives more than two answers, like vbYesNoCancel or vbAbortRetyIgnore.

If there is nothing after the Select or If-Then block, then you drop the Exit Sub if you want.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.