Results 1 to 4 of 4

Thread: [RESOLVED] Custom MessageBox Options

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Resolved [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??

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Custom MessageBox Options

    That list that you refer to is an Enum. You can create one yourself like so:

    vb Code:
    1. Public Enum MyMessageBoxButtons As Integer
    2.         OK = 1
    3.         RetryCancel = 2
    4.         YesNo = 3
    5.     'etc
    6.     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:
    1. Sub MyProcedure(ByVal Buttons As MyMessageBoxButtons)
    2.     'do stuff here
    3. 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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Custom MessageBox Options

    Thanx very much. it worked.

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] Custom MessageBox Options

    No problem
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width