# Visual Basic > Universal Windows Platform and Modern Windows Experience >  Creating a MessageBox in a Windows 8 Store app - Sample

## MrGTI

Hello.

Once I figured out how to create a message box in a Windows 8 Store app, I made myself a new class that allowed me to easily create message boxes using the way I had always done so in all of my WinForm applications. I have attached this class so that others can use it in the hopes that it makes programming a Windows 8 app easier.

Take the attached class file and add it to your solution. CustomMessageBoxClass.vb

Then you can easily create a message box using code from these examples:



```
    Private Async Sub btnTHREE_Click(sender As Object, e As RoutedEventArgs) Handles btnTHREE.Click
        Dim xMsgBox3 As New EnhancedMessageBox("Shall I format and re-install the operating system?", "Start Over", MessageBoxButtons.OkCancel)
        Dim xResult3 As DialogResult = Await xMsgBox3.ShowDialog
        If xResult3 = DialogResult.OK Then
            lblButtonThreeResult.Text = "You have agreed to re-install the OS."
        Else
            lblButtonThreeResult.Text = "You clicked the Cancel button."
        End If
    End Sub

    Private Async Sub btnFOUR_Click(sender As Object, e As RoutedEventArgs) Handles btnFOUR.Click
        Dim xMsgBox4 As New EnhancedMessageBox("Hurry and click the Yes button!", "", MessageBoxButtons.YesNoCancel)
        Await xMsgBox4.ShowDialog
    End Sub
```

*Note #1:* Yes I realize that the new method of creating a message box in much more versatile. This is not meant to stop anyone from using the new method. This is simply an aid to help people like myself who struggle to get some of the basics figured out. 

*Note #2:* I built and tested this on Windows 8.1 using Visual Studio 2013, as a Windows 8 Store app. I have not tested it as code for a Windows Phone 8 app.

----------


## 4x2y

I built and tested this on Windows 10 using Visual Studio 2015, as a Universal Windows app running on Lumia 640 XL phone, only message box with two buttons can be shown, if three buttons specified, the message box doesn't appear at all and the code after *Await xMsgBox.ShowDialog* executed!

----------


## MrGTI

Hi 4x2y.

I tried my revised Windows 10 (UWP) version, and yes, you can only use 2 buttons on Windows 10 Phone. I'm guessing it's a limitation built into the MessageDialog class for mobile devices. Nice job discovering that!

In reality, a message box should just be used as a boolean (ie: do you want to save? yes or no). If you're asking something with 3 answers, you should probably be using a radio button or a list box.

----------


## techgnome

That's debatable... "XYZ has been modified, do you wish to save before exiting?" - yes, no, cancel... then again, I think about all the mobile apps I use, how they work... don't really know that I've ever seen a three option dialog anywhere.

-tg

----------


## 4x2y

I think it is limited to two buttons only for mobile apps because the device's *Back* button is used to cancel the message box.

----------


## techgnome

Yeah, I kinda realized that after the fact. ;P 

-tg

----------

