How to create my own MsgBox

Hello
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
FooKy

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

Open in new window

LVL 11
f_o_o_k_yAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dampseyConnect With a Mentor Commented:
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
0
 
appariCommented:

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.
0
 
dampseyCommented:
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 = messagebox.show(text, caption);
if (xxx == dialogresult.Ok)
  return myDialogResult.Accept;
}
}

//calling

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 ;)
0
 
AUmidhCommented:
on frmConfirm.vb calling

DialogResult dr=frmConfirm.ShowDialog();
if(dr==DialogResult.OK)
// 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.
frmConfirm.Close();
0
All Courses

From novice to tech pro — start learning today.