How to create my own MsgBox

Example belowe shows what I want to do but it's with MsgBox .
I need to do this but instead using MsgBox I want to use my frmConfirm.vb

How can I return value from frmConfirm.vb
Best Regards

' frmMain.vb
Dim answer As MsgBoxResult
answer = MsgBox("Are you sure?", MsgBoxStyle.YesNo, "Warning!")
If answer = MsgBoxResult.Yes Then
End If

Open in new window

LVL 11
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if the options of DialoResult is enough for you,
just create a form.
Show it with ShowDialog
and before closing set the DialogResult property of the form to something you want

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

suppose your own msgbox form has two buttons Yes and No. select the Yes button set its DialogResult property to  YES and the other button set it to NO.
now show your form using showDialog method instead of show method. the form automatically returns YES or NO depending on the button you clicked.
if you entirely new features.
Define an enum. and define your alternatives.
Then define a variable in to your ConfirmForm and look for the variable value after closing.

enum myDialogResult
Accept, Refect, None, All, etc
public class ConfirmForm
public static myDialogResult  Show(string text, string caption)
dialogresult xxx =, caption);
if (xxx == dialogresult.Ok)
  return myDialogResult.Accept;


public class Form1: form

private void Button1_Click(....)
if (ConfirmForm.Show() == myDialogResult.Accept)
//do stuff

I wrote code in here. so there may be typing errors. This is just for giving an idea. This is not a complete solution ;)
on frmConfirm.vb calling

DialogResult dr=frmConfirm.ShowDialog();
// Do OK COde
else if(dr==DialogResult.Cancel)
// Do Cancel...
else if ........... Retry, abort, no ,yes. etc...

and on before closing.... frmConfirm.vb

frmConfirm.DialogResult=DialogResult.OK or whatever you assign.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.