code throws error for a minor diff.

ananas

Member
Joined
May 18, 2009
Messages
6
Programming Experience
Beginner
hello everyone
the extract of code shown below throws an error when i don't include the "demo" (the title name of the dialog box), why does it do so? isn't it supposed to be an optional detail? otherwise the code seems to work fine.
VB.NET:
If MessageBox.Show("r u sure to delete " & selectedcustomer.name & "? ", "demo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then

                Dim deletecustomer As customer = selectedcustomer
                _customers.Remove(deletecustomer)
                ListBox1.Items.Remove(deletecustomer)

            End If
 
MessageBox.Show("Really delete " & selectedcustomer.name & "? ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
 
so is it really necessary to add that parameter, becos when i added simple messageboxes i did not supply with the title of the dialog box. then why does it demand me in this context?
 
MessageBox.Show Method (System.Windows.Forms) is the overload list for Messagebox

It doesnt contain a Show(string, Buttons, Icon) overload so yes, youre always going to have to use one of the overloads it does support, like this one:

Show(string, string, Buttons, Icon)


The compiler only knows what version of an overloaded method to call by looking at the number and type and order of the arguments provided. if you don't provide one of them, then it can't just read your mind or decide on its own what it wants to call!


Adding a title to a messagebox makes it look more professional. use it to present a shorter form of your question, for power users who don't want to read the whole detailed (cough) error text you have written
 
I usually also include the application name in the message box title, makes it easier to see what application is throwing the message.
 
Back
Top