Help please!

Discussion in 'Code Snippets and Tutorials' started by test123, Mar 30, 2007.

  1. test123

    test123 Level IV

    Joined:
    Nov 3, 2006
    Messages:
    935
    Likes Received:
    0
    Location:
    Australia
    alright i have a messagebox in a game im making...

    heres the code:

    Code (Text):
    1. MessageBox.Show("Play Again?", "You Win!", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    what i want to know is how can i add code to the yes and no buttons inside the message box?
     
  2. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Store the button result in a variable, like this:
    Code (Text):
    1. Dim intAnswer as Integer
    2. intAnswer = MessageBox.Show("Play Again?", "You Win!", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    3. If intAnswer = 6 Then
    4. 'code to execute if the answer is "YES"
    5. Else
    6. 'code to execute if the answer is "NO"
    7. End If
    You're using VB.NET, right? Well, I dunno if it works with that version, but it works for VB6!!!
     
  3. test123

    test123 Level IV

    Joined:
    Nov 3, 2006
    Messages:
    935
    Likes Received:
    0
    Location:
    Australia
    hey

    thanks ricky :D