Noob question

Discussion in 'Programming General' started by Jeroentjo, Jan 6, 2012.

Noob question
  1. Unread #1 - Jan 6, 2012 at 5:50 PM
  2. Jeroentjo
    Joined:
    Jul 12, 2011
    Posts:
    246
    Referrals:
    0
    Sythe Gold:
    6

    Jeroentjo Active Member

    Noob question

    hey, i started with a mini project on .NET today, im really a starting beginner. ;p
    code;
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
    If MsgBox("Are you sure you wanna quit?", MsgBoxStyle.OkCancel, MessageBoxIcon.Question = Windows.Forms.DialogResult.Yes) Then End
    If MsgBox("Are you sure you wanna quit?", MsgBoxStyle.OkCancel, MessageBoxIcon.Question = Windows.Forms.DialogResult.Cancel) Then

    End If
    End Sub

    End Class

    _______________________________
    TLDR: Basicly its a "Quit" button and i need to make that if u press cancel the application still stays open, dont flame about my skills or w/e.
    Ty!
     
  3. Unread #2 - Jan 6, 2012 at 11:23 PM
  4. matt_sells
    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    matt_sells Member

    Noob question

    so you want a yes/no messagebox?
    If MessageBox.Show("name/stuff", "something", MessageBoxButtons.okcancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
    MessageBox.Show("you want to quit") 'this = ok
    Else
    MessageBox.Show("you don't want to quit") 'this = cancel
    End If

    basically all you did wrong was forget that you needed ELSE
     
  5. Unread #3 - Jan 7, 2012 at 5:21 AM
  6. Jeroentjo
    Joined:
    Jul 12, 2011
    Posts:
    246
    Referrals:
    0
    Sythe Gold:
    6

    Jeroentjo Active Member

    Noob question

    thanks man! :), but i need to make when u press "OK" that you quit, now it says "You dont want to quit", but i made
    If MessageBox.Show("Are you sure you wanna Quit?", "Quit", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then End
    MessageBox.Show("you want to quit")
    Else
    MsgBox("you don't want to quit", MessageBoxIcon.Exclamation) 'this = cancel
    End If
    and it gave me 2 errors.. :(
     
  7. Unread #4 - Jan 7, 2012 at 7:18 AM
  8. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Noob question

    Code:
            If MsgBox("Are you sure you want to quit?", MsgBoxStyle.OkCancel) = DialogResult.OK Then
                End
            End If
    You don't need to put the second MsgBox since it doesn't do anything. That will only make it show twice.

    If you want to have different things happen, do something like this:
    Code:
            Dim result As DialogResult
            result = MsgBox("Are you sure you want to quit?", MsgBoxStyle.OkCancel)
            If result = DialogResult.OK Then
                End
            ElseIf result = DialogResult.Cancel Then
                'Do other stuff here.
            End If
     
  9. Unread #5 - Jan 7, 2012 at 10:13 PM
  10. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Noob question

    +1 for Darth :D
    /spam
     
  11. Unread #6 - Jan 8, 2012 at 11:35 AM
  12. Jeroentjo
    Joined:
    Jul 12, 2011
    Posts:
    246
    Referrals:
    0
    Sythe Gold:
    6

    Jeroentjo Active Member

    Noob question

    thanks Darth. =)
     
  13. Unread #7 - Jan 9, 2012 at 6:52 PM
  14. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    Noob question

    Please, for future reference, use the code tags.
    Code:
    [code]
    [/code]
     
  15. Unread #8 - Jan 20, 2012 at 8:19 PM
  16. jasonfish4
    Joined:
    Jan 20, 2012
    Posts:
    30
    Referrals:
    1
    Sythe Gold:
    0

    jasonfish4 Member

    Noob question

    Do a me.close()
    and then do a form2.show()
    quickly.
     
< [Source] Easy global hotkeys for VB.net | C++ help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site