Adblock breaks this site

Noob question

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

  1. Jeroentjo

    Jeroentjo Active Member

    Joined:
    Jul 12, 2011
    Posts:
    246
    Referrals:
    0
    Sythe Gold:
    6
    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!
     
  2. matt_sells

    matt_sells Member

    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0
    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
     
  3. Jeroentjo

    Jeroentjo Active Member

    Joined:
    Jul 12, 2011
    Posts:
    246
    Referrals:
    0
    Sythe Gold:
    6
    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.. :(
     
  4. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    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
     
  5. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Noob question

    +1 for Darth :D
    /spam
     
  6. Jeroentjo

    Jeroentjo Active Member

    Joined:
    Jul 12, 2011
    Posts:
    246
    Referrals:
    0
    Sythe Gold:
    6
    Noob question

    thanks Darth. =)
     
  7. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    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
    Noob question

    Please, for future reference, use the code tags.
    Code:
    [code]
    [/code]
     
  8. jasonfish4

    jasonfish4 Member

    Joined:
    Jan 20, 2012
    Posts:
    30
    Referrals:
    1
    Sythe Gold:
    0
    Noob question

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


 
 
Adblock breaks this site