Message Box

Use this board to post your code snippets - tips and tricks
4 posts Page 1 of 1
Contributors
User avatar
visualbasicje
New Member
New Member
Posts: 23
Joined: Thu Mar 04, 2010 3:32 pm

Message Box
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;
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Message Box
Lewis
Siplified version
MsgBox("Do you want to continue?", MsgBoxStyle.Critical, "MsgBox Demonstration")

You could do that but your code is cool aswell ;)
Image
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1891
Joined: Wed Dec 16, 2009 9:56 pm

Re: Message Box
zachman61
it has the option for yes or no besides clicking no and still continuing
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
jeezy09
VIP - Donator
VIP - Donator
Posts: 25
Joined: Wed Mar 31, 2010 1:51 am

Re: Message Box
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
4 posts Page 1 of 1
Return to “Quick Snips”