Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Hybrid View

  1. #1
    o0OpurezO0o's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    behind you.
    Posts
    354
    Reputation
    10
    Thanks
    26
    My Mood
    Sick

    [Help]Message Box[Solved]

    I was trying to make a notepad with a Advance save system, the code is:

    MsgBox("Do you want to Save?", vbQuestion+vbYesNoCancel, "Do you want to Save?")

    If MsgBoxResult.Yes then
    *Private Coding*
    End If

    If MsgBoxResult.No Then
    End
    End If

    If MsgBoxResult.Cancel Then
    Stop
    End If

    It keeps skipping and going to the save if i hit "No" or "Cancel".

    Whats wrong? Anything Missing?

  2. #2
    willrulz188's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Ohio?
    Posts
    1,786
    Reputation
    35
    Thanks
    231
    My Mood
    Amazed
    If MsgBoxResult.Yes then
    *Private Coding*
    End If

    'Nothing else so you dont need it

    If MsgBoxResult.Cancel Then
    Exit sub
    'or e.cancel
    End If
    Last edited by willrulz188; 01-23-2011 at 11:55 AM.
    Question ALL statements! ?
    You're in denial that you're in denial. ?
    [img]https://i360.photobucke*****m/albums/oo45/blood188/Untitled-3.jpg?t=1284590977[/img]

  3. #3
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,136
    My Mood
    Dead
    Code:
    Dim i As Integer = MsgBox("Do you want to Save?", vbQuestion+vbYesNoCancel, "Do you want to Save?")
    If i = 2 Then
    Stop
    Elseif i=6 Then
    *Private Coding*
    Elseif i = 7 Then
    End
    End If

  4. #4
    o0OpurezO0o's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    behind you.
    Posts
    354
    Reputation
    10
    Thanks
    26
    My Mood
    Sick
    it still goes to the "Yes" Command.

    Does anyone know?


    Thanks Haddson.
    Last edited by o0OpurezO0o; 01-23-2011 at 12:47 PM.

  5. #5
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,136
    My Mood
    Dead
    Quote Originally Posted by o0OpurezO0o View Post
    it still goes to the "Yes" Command.

    Does anyone know?


    Thanks Haddson.
    No Problem. Btw, my name's Hassan xD !

  6. #6
    willrulz188's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Ohio?
    Posts
    1,786
    Reputation
    35
    Thanks
    231
    My Mood
    Amazed
    Quote Originally Posted by o0OpurezO0o View Post
    it still goes to the "Yes" Command.

    Does anyone know?


    Thanks Haddson.
    maybe because its already saved
    Question ALL statements! ?
    You're in denial that you're in denial. ?
    [img]https://i360.photobucke*****m/albums/oo45/blood188/Untitled-3.jpg?t=1284590977[/img]

  7. #7
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,136
    My Mood
    Dead
    Quote Originally Posted by willrulz188 View Post
    maybe because its already saved


  8. #8
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Haddson....ahahahaha



  9. #9
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,136
    My Mood
    Dead
    Quote Originally Posted by Blubb1337 View Post
    Haddson....ahahahaha
    Lol'd too. Get on MSN -.-

  10. #10
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed
    Code:
    Dim Msgbox1 As DialogResult = MsgBox("AHAHAHA", MsgBoxStyle.YesNoCancel Or MsgBoxStyle.Question, "AHAHA")
            If Msgbox1 = Windows.Forms.DialogResult.Yes Then
                MsgBox("You Pressed YES")
            ElseIf Msgbox1 = Windows.Forms.DialogResult.No Then
                MsgBox("You Pressed NO")
            ElseIf Msgbox1 = Windows.Forms.DialogResult.Cancel Then
                MsgBox("You Pressed CAncel")
            End If

  11. #11
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Code structure is wrong. In your code you have

    [highlight=vbnet]
    MsgBox("Do you want to Save?", vbQuestion+vbYesNoCancel, "Do you want to Save?")
    If MsgBoxResult.Yes then
    *Private Coding*
    End If
    If MsgBoxResult.No Then
    End
    End If
    If MsgBoxResult.Cancel Then
    Stop
    End If
    [/highlight]

    It should be

    [highlight=vbnet]
    Dim Result As DialogResult
    Result = MessageBox.Show("Do you want to save?", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
    'This will check what was clicked inside the dialog box declared as result
    If Result = vbYes Then
    'Your Code
    ElseIf Result = vbNo Then
    'Something else
    ElseIf Result = vbCancel Then
    'do nothiing
    End If
    [/highlight]

    There should be no issues, let me know.

    Fact is , it's all about the code and how it is structured, If statements should not end until you are done checking for what you want to check for.

    In the same way a real If-->then Statement works.

    If I have an apple
    I have an Orange
    Elseif I have a pinapple
    I do not have a apple
    ----------------------
    I do not have an Pineapple.

    What is then true?
    You can check to see if I have an apple, and can assume I do, but you will also have to continue to check and see If I have an orange (which I do) if you end the check there, you will never find that I have an orange

    abstract explanation, but hopefully you understand.
    Plus it is best to declare the result anyway



    Last edited by NextGen1; 01-23-2011 at 02:51 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  12. #12
    Born2Amuse's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Sydney, Australia
    Posts
    36
    Reputation
    10
    Thanks
    9
    My Mood
    Innocent
    Yes, the best way is to declare the result if you the possibility of more than two return types, otherwise you can use the following format:
    [highlight=vbnet]If Msgbox("Do you want to retry ?", MsgBoxStyle.YesNo,"Msgbox Test")=MsgboxResult.vbYes Then
    Msgbox("You pressed Yes")
    Else
    Msgbox("You pressed No")
    End If[/highlight]
    Can save some lines, but doesn't really matter.

  13. #13
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Kinda does matter, But irrelevant,

    in either case however, By declaring it first you leave yourself open for numerous options and many ways to use it, your way is static, used for yesno only, in this case we can use
    Okonly,Yesno,YesNoCancel,Okcanel, You get the idea. Yours wouldn't even work with his scenario.



    Last edited by NextGen1; 01-23-2011 at 10:06 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  14. #14
    Born2Amuse's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Sydney, Australia
    Posts
    36
    Reputation
    10
    Thanks
    9
    My Mood
    Innocent
    Let me quote my self:

    Yes, the best way is to declare the result if you the possibility of more than two return values.
    You should've read that before giving me a lecture. Thank you.
    *Correction in bold*.

  15. #15
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,136
    My Mood
    Dead
    Quote Originally Posted by Born2Amuse View Post
    Let me quote my self:

    Yes, the best way is to declare the result if you the possibility of more than two return values.
    You should've read that before giving me a lecture. Thank you.
    *Correction in bold*.
    Well, you are right but you can't argue with him. Get used to it already.

Page 1 of 2 12 LastLast