Jump to content
xisto Community
Sign in to follow this  
MarCrush

Msgbox Here is a simple way and lists of MsgBoxes.

Recommended Posts

hmm.. maybe you could post how to code what happens when each button is pressed (incase there is more than the OK button)..i don't use too much of VB myself.. C#.net is nice.

Share this post


Link to post
Share on other sites

Here are lists of MsgBoxes:

 

Syntax:

MsgBox Prompt, MsgBoxStyle, Title, HelpFile

 

MsgBox "Uh, text!", , "Uh, Title!"

MsgBox "Uh, text!", vbCritical, "Uh, Title!"

MsgBox "Uh, text!", vbExclamation, "Uh, Title!"

MsgBox "Uh, text!", vbInformation, "Uh, Title!"

MsgBox "Uh, text!", vbOKCancel, "Uh, Title!"

MsgBox "Uh, text!", vbQuestion, "Uh, Title!"

MsgBox "Uh, text!", vbYesNo, "Uh, Title!"

MsgBox "Uh, text!", vbYesNoCancel, "Uh, Title!"

MsgBox "Uh, text!", vbRetryCancel, "Uh, Title!"

MsgBox "Uh, text!", vbOKOnly, "Uh, Title!"

MsgBox "Uh, text!", vbAbortRetryIgnore, "Uh, Title!"

MsgBox "Uh, text!", vbMsgBoxHelpButton, "Uh, Title!", "C:\HelpFile.hlp"

 

You can also combine them:

MsgBox "Uh, text!", vbExclamation + vbYesNoCancel, "Uh, Title!"

 

This is great for noobs.

147540[/snapback]


i think this guy is only tryin yo get some points

Share this post


Link to post
Share on other sites

hmm.. maybe you could post how to code what happens when each button is pressed (incase there is more than the OK button)..

i don't use too much of VB myself.. C#.net is nice.

147584[/snapback]


here is the code for a yes/no/cancel msgbox

ync = MsgBox("Click on yes or no or cancel", vbYesNoCancel + vbQuestion, "Title")If ync = vbYes Then'code goes hereElseIf ync = vbNo Then'code goes hereElseIf ync = vbCancel Then'code goes hereEnd If

Share this post


Link to post
Share on other sites

i think this guy is only tryin yo get some points

159578[/snapback]

Lol, I really don't think he's trying only to get credits, but i can't find his post useful anyway... CheerS!! :ph34r:

Share this post


Link to post
Share on other sites

Here are lists of MsgBoxes:
Syntax:
MsgBox Prompt, MsgBoxStyle, Title, HelpFile

MsgBox "Uh, text!", , "Uh, Title!"
MsgBox "Uh, text!", vbCritical, "Uh, Title!"
MsgBox "Uh, text!", vbExclamation, "Uh, Title!"
MsgBox "Uh, text!", vbInformation, "Uh, Title!"
MsgBox "Uh, text!", vbOKCancel, "Uh, Title!"
MsgBox "Uh, text!", vbQuestion, "Uh, Title!"
MsgBox "Uh, text!", vbYesNo, "Uh, Title!"
MsgBox "Uh, text!", vbYesNoCancel, "Uh, Title!"
MsgBox "Uh, text!", vbRetryCancel, "Uh, Title!"
MsgBox "Uh, text!", vbOKOnly, "Uh, Title!"
MsgBox "Uh, text!", vbAbortRetryIgnore, "Uh, Title!"
MsgBox "Uh, text!", vbMsgBoxHelpButton, "Uh, Title!", "C:\HelpFile.hlp"

You can also combine them:
MsgBox "Uh, text!", vbExclamation + vbYesNoCancel, "Uh, Title!"

This is great for noobs.


Thankx, you can use number , for exam: 16 = vbCritical

Share this post


Link to post
Share on other sites

Yes. iT IS GOOD. bUT YOU KNOW, IT IS simple version of WinAPI's mESSAGEBoX function. MessageBox has got more possibilities.

196629[/snapback]

the visual basic 6's MsgBox class is a wrapper for the MessageBoxA WinAPI call. I think it fills in something like this:

MsgBox "Some text", "a title" 
and replaces it with:

MessageBox(NULL, "Some text", "a title", NULL);

the msdn documentation for MessageBoxA says:

int MessageBox(     

    HWND hWnd,

    LPCTSTR lpText,

    LPCTSTR lpCaption,

    UINT uType

);

 

so, all the MsgBox class does is replace the hWnd (handle) of the window with NULL and if you dont fill in a parameter it will full in NULL while calling the API call.

 

hope this clears up some questions with the MsgBox class.

Share this post


Link to post
Share on other sites

Hmmm... He's talking about the types of Messagebox in VB.NET or VB.

Probably many doesn't understand what the code does...

Let me explain them with screenshots..

 

Normal Message Boxes

Windows.Forms.MessageBox.Show("This is a plain messagebox.")
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("This is a plain messagebox." & vbCrLf & "It's got a caption too.", "This is the caption.")
Is shown as Posted Image

----------------------------------------------------------------------------------------------

 

Message Boxes with Different Button Types

Windows.Forms.MessageBox.Show("It's got Abort, Retry, Cancel buttons.", "", MessageBoxButtons.AbortRetryIgnore)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("It's got OK button.", "", MessageBoxButtons.OK)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("It's got OK, Cancel buttons.", "", MessageBoxButtons.OKCancel)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("It's got Retry, Cancel buttons.", "", MessageBoxButtons.RetryCancel)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("It's got Yes, No buttons.", "", MessageBoxButtons.YesNo)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("It's got Yes, No, Cancel buttons.", "", MessageBoxButtons.YesNoCancel)
Is shown as Posted Image

----------------------------------------------------------------------------------------------

 

Message Boxes with Different Alert Types

Windows.Forms.MessageBox.Show("An Asterisk type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("An Error type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("An Exclamation type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("A Hand type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Hand)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("An Information type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("A None type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.None)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("A Question type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Question)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("A Stop type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Is shown as Posted Image

 

Windows.Forms.MessageBox.Show("A Warning type icon.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Is shown as Posted Image

 

I've created an example on VB.NET 2003.

You can download the program here to view all the types of Messageboxes.

Download: http://www.freeuploader.com/view.php/69424.zip

Source Codes: http://www.freeuploader.com/view.php/69426.zip

Share this post


Link to post
Share on other sites

yes, the windows.forms.messagebox.show is also a wrapper for the MessageBoxA API call i beleive. it is basically the same as Visual Basic 6.0's MsgBox function, just a slightly different syntax. I never bothered with vb.net because c++ is just still alot better for directly accessing memory... however, if managed code becomes the new standard, i guess i would do .netbtw, MessageBoxButtons.OK and etc. are just constants representing hex code that is defined in some windows header that is included when you compile.

Share this post


Link to post
Share on other sites

You can change the caption, or the title, of any messagebox. The only thing you cannot change is the text of the buttons in a messagebox.However if you want to have a customised button text, you can make another form that opens as a dialog, to imitate the effects of a messagebox. This way, not even you can customise the button text of the messagebox, you can also add background pictures, sound effects, colors, and even add a customised icon.Basically just treat the form as a messagebox and customise it..

Share this post


Link to post
Share on other sites

Hi

 

You can do as Inspiron said,make a whole new form,and place controls as you like them.

 

I was never good in subclassing,but I believe changing button captions can be done using subclassing.I would love to give the example,but as I said,I'm no good with subclassing.As always,I direct people to use the web,Yahoo or Google a bit,and dig out some information that is of interest to you.Because,nothing can stick in peoples minds better,than hard way of finding some info out.Check Planet Source Code (http://www.planet-source-code.com/vb/default.asp?lngWId=1) for examples on MsgBox usage,maybe there are some of customizing this function.

 

Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.