[RESOLVED] Custom MessageBox Options
This may sound like a stupid question (and maybe is):
I want to create my own custom MessageBox.
The default message box from VB contains a few options (as a parameter) like:
MessageBoxButtons.OK
MessageBoxButtons.RetryCancel
MessageBoxButtons.YesNo
MessageBoxButtons.OKCancel
etc...
How can I create a sub that also has a list of options the user can choose from??
Re: Custom MessageBox Options
That list that you refer to is an Enum. You can create one yourself like so:
vb Code:
Public Enum MyMessageBoxButtons As Integer
OK = 1
RetryCancel = 2
YesNo = 3
'etc
End Enum
You assign numbers to each option because an Enum is basically just a fancy way of displaying a number. Its just nicer for a developer to see a list of options that actually mean something, rather than just being told that they have to enter a number which corresponds to one of the possible options.
Then if you want to create a sub that accepts this Enum as one of its arguments, you just do it like so:
vb Code:
Sub MyProcedure(ByVal Buttons As MyMessageBoxButtons)
'do stuff here
End Sub
Now when you come to call that method in your code you will see that when you get to the part where you need to enter the first argument (well in this case there is only one) it will bring up your Enum list just like it does when you use the standard MessageBox :)
Re: Custom MessageBox Options
Thanx very much. it worked.
Re: [RESOLVED] Custom MessageBox Options