Page 1 of 1

Message Box

Posted: Fri Mar 05, 2010 10:23 am
by visualbasicje
Although most of you already know how to do this, I will still post this for the VB ''newbs''.
Code: Select all
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Do you want to continue?"   ' Message you want to display
style = MsgBoxStyle.DefaultButton2 Or _
   MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
title = "MsgBox Demonstration"   ' Msgbox title

response = MsgBox(msg, style, title)
If response = MsgBoxResult.Yes Then   'if user choses yes
   ' Doe iets.
Else
   ' Doe iets.
End If



cya wahooo;

Re: Message Box

Posted: Fri Mar 05, 2010 7:52 pm
by Lewis
Siplified version
MsgBox("Do you want to continue?", MsgBoxStyle.Critical, "MsgBox Demonstration")

You could do that but your code is cool aswell ;)

Re: Message Box

Posted: Fri Apr 16, 2010 11:15 pm
by zachman61
it has the option for yes or no besides clicking no and still continuing

Re: Message Box

Posted: Wed May 05, 2010 11:33 pm
by jeezy09
I use this a ton but do it a lil different lol shorter version but both are nice =p


Dim answer As Integer
answer = MsgBox("Would you like to close", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If answer = vbYes Then
Me.Close()
Else
Me.Show()

End If