Visual Basic Tutorial – 40 – MessageBox Input

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

43 responses to “Visual Basic Tutorial – 40 – MessageBox Input”

  1. partners Avatar

    Dim x As String = MessageBox.Show("M", "T", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)
    If x = Windows.Forms.DialogResult.Abort Then
    MessageBox.Show("A")
    ElseIf x = Windows.Forms.DialogResult.Retry Then
    MessageBox.Show("R")
    Else
    MessageBox.Show("I")
    End If

  2. Tobi Ologbenla Avatar

    my programme keeps on saying too many arguements but i copied the code word for word.

  3. KGentard Avatar

    Sam, any idea why when I create Else IF statements in the code for the additional buttons that I have to click the buttons multiple times in order to get the response. In the code below, the order is Abort/Retry/Ignore. I have to Click Abort once, Retry Twice, and Ignore three times to get the Messagebox.Show output. This is in Visual Studio Pro 2015 so replace Windows.Forms.DialogResult.result with DialogResult.result

    Public Class Form1
    Private Sub BtnMessage_Click(sender As Object, e As EventArgs) Handles BtnMessage.Click
    If MessageBox.Show("Click Something", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question) = DialogResult.Abort Then
    MessageBox.Show("aborted")
    ElseIf MessageBox.Show("Click Something", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question) = DialogResult.Retry Then
    MessageBox.Show("Retrying Now")
    ElseIf MessageBox.Show("Click Something", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question) = DialogResult.Ignore Then
    MessageBox.Show("Ignored")
    End If
    End Sub
    End Class

  4. Blue Glue Avatar

    So helpfu,l thx bro!!

  5. Hack Protect Avatar

    thank you very much

  6. Chris Andujar Avatar

    Dim Selection As String = Nothing

    Selection = MessageBox.Show("Message", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information)

    Select Case Selection

    Case Windows.Forms.DialogResult.Abort
    MessageBox.Show("FOR ABORT")
    Case Windows.Forms.DialogResult.Retry
    MessageBox.Show("FOR RETRY")
    Case Else
    MessageBox.Show("FOR IGNORE")

    End Select

  7. WarlordSquerk Avatar

    FYI I'm using Visual Studio 2015 Community Edition and "Windows.Forms.DialogResult.Abort" doesn't work. It says "Forms is not a member of windows". Instead what you gotta do is just use "DialogResult.Abort"

  8. Ronald Arjune Avatar

    Why are you fucking messing with my mind?

  9. Yoferen Untar Avatar

    why we directly put the if statement rather than, put the messagebox.show first and then make if statements??]

  10. Jose Avila Avatar

    Great tutorials. I'm learning a lot and having fun. Tx!

  11. FeelDaRush15 Avatar

    This has helped me so much!! Thx

  12. For Nachos Avatar

    For those who only managed to have two printed out (e.g. abort and retry, but can't get the messagebox for ignored to show up) then you need to assign the messagebox to a variable, so it would look something like this:

     Dim Selection As String

     Selection = MessageBox.Show("Message", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Information)

       If Selection = Windows.Forms.DialogResult.Abort Then
                MessageBox.Show("Aborted")
            ElseIf Selection = Windows.Forms.DialogResult.Retry Then
                MessageBox.Show("Retry")
            ElseIf Selection = Windows.Forms.DialogResult.Ignore Then
                MessageBox.Show("Ignored")
            End If

      End Sub

    End Class

  13. Mama Duck Avatar

    I just wanted to comment that I am very impressed with the organized approach you are taking in your tutorials. Very methodical and clear. Unusual for a techy!

  14. zeke finan Avatar

    Thanks for the Tutorial! 🙂
    The Select Case is easier than the if then :/

  15. CryWater Avatar

    Its opening 500 times the message box. Any help?

  16. Bruce Wayne Avatar

            Dim Selection As String = MessageBox.Show("click something", "", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)

            Select Case Selection

                Case Windows.Forms.DialogResult.Abort
                    MessageBox.Show("Aborted")

                Case Windows.Forms.DialogResult.Retry
                    MessageBox.Show("Retry")

                Case Windows.Forms.DialogResult.Ignore
                    MessageBox.Show("Ignore")

            End Select

  17. Bruce Wayne Avatar

            Dim Selection As String = MessageBox.Show("click something", "", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)

            If Selection = Windows.Forms.DialogResult.Abort Then
                MessageBox.Show("Aborted")

            ElseIf Selection = Windows.Forms.DialogResult.Retry Then
                MessageBox.Show("Retry")

            Else
                MessageBox.Show("Ignore")

            End If

  18. HołKocz12 Avatar

    Hello
    Im Poland.
    I create my first program (Calculator) and I dont know why continue next programms in Virtual Basic . 

    Thanks 

  19. jupida Avatar

     Dim asd As String

            asd = MessageBox.Show("Choose Something", "Hello", MessageBoxButtons.AbortRetryIgnore)

            Select Case asd
                Case Windows.Forms.DialogResult.Abort
                    MsgBox("abort")
                Case Windows.Forms.DialogResult.Retry
                    MsgBox("retry")
                Case Windows.Forms.DialogResult.Ignore
                    MsgBox("ignore")

            End Select

    Just done it – this is the correct way guys 

  20. XenoContact Avatar

    I assume Windows.Forms.DialogResult.Ret­ry, for example, is an integer then?

  21. Albin Hermansson Avatar

    Select Case MessageBox.Show("Click!", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)
    Case Windows.Forms.DialogResult.Abort
    MessageBox.Show("Aborted")
    Case Windows.Forms.DialogResult.Ignore
    MessageBox.Show("Ignored")
    Case Windows.Forms.DialogResult.Retry
    MessageBox.Show("Retried")
    Select Case is way easier to use! Just a tip!

  22. BiggestTrollAlive42 Avatar

    Select Case intResult
    Case Windows.Forms.DialogResult.Ignore
    MessageBox.Show("You ignored it")
    Case Windows.Forms.DialogResult.Retry
    MessageBox.Show("Try again cowboy!")
    Case Windows.Forms.DialogResult.Abort
    MessageBox.Show("You aborted a baby")
    End Select

    Select makes it so much easier and cleaner though 🙂

  23. PinGsamY Avatar

    how is that gonna work , how do you know MessageBox.Show("Click Something", "title", MessageBoxButtons.AbortRetryIg­nore, MessageBoxIcon.Question) is an integer type?

  24. sudacaenny Avatar

    Hello sam your tutorials are awesome but I need a little help on this tutorial. I am trying to use the Select case for this tutorial instead of the if statement, but I am having a hard time you showed how to use the case selector for console aplications but I dont know how to do it in this case windows ap

  25. Mizaan Shamaun Avatar

    /playlist?list=PL28EF3CEDC96F55C2

  26. calfred2808 Avatar

    to add "retrying" we can use elseif copy ElseIf MessageBox.Show("hellow world", "alfred", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Retry Then

  27. Jemmeh Avatar

    That is a good way of doing it. 😀

  28. badadaha Avatar

    @2pimpinout thanx i was trying to figure out what variable type to use. 😛

  29. Bassie en nog wat Avatar

    does anyone knows how i can change my default language?

  30. Vitaliy Avatar

    It is better if you make it like this:
    Dim Result As DialogResult = MessageBox.Show("Click Something.", "title", MessageBoxButtons.AbortRetryIg­nore, MessageBoxIcon.Question)

    If Result = Windows.Forms.DialogResult.Abort Then
    MsgBox("Aborted!)
    ElseIf Result = Windows.Forms.DialogResult.Cancel Then
    MsgBox("Canceled")
    End If

  31. zc0rp10 Avatar

    I ended up using the select option, looked like this:

    Private Sub btnMessage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMessage.Click

    Select Case MessageBox.Show("Click Something.", "title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)

    Case Windows.Forms.DialogResult.Abort
    MessageBox.Show("Aborted")

    Case Windows.Forms.DialogResult.Retry
    MessageBox.Show("Retrying")

    Case Windows.Forms.DialogResult.Ignore
    MessageBox.Show("Ignored")

    End Select

  32. Marko Perica Avatar

    If MessageBox.Show("Click something", "Title", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Abort Then
    MessageBox.Show("Aborted")
    ElseIf Windows.Forms.DialogResult.Retry Then
    MessageBox.Show("Retrying")
    ElseIf Windows.Forms.DialogResult.Ignore Then
    MessageBox.Show("Ignoring!")
    Im having problems with thos: when i click ignore it sads retrying.. WTF?

  33. Felix Montero Avatar

    @Zeiterius
    i recommend to watch the console tutorial first, well it's easy for you to understand that if you know already some language.

  34. djuroue1 Avatar

    @gjh33 Congraz man Dim message As string = MessageBox.Show("clic smth", "tittle", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question) and then just if … retry if ignore if aborted an worked :)))
    before i have your comment i have tried just if if if with whole message thibg and work but just if click one time on first,two time on second and three time on tird ;((( Who will try that way they will know what i am talking about.

  35. gjh33 Avatar

    couldn't you put the MessageBox.Show() inside a variable then test the variable for results. That's how its done in VBS.

    Also, Does anyone else want to punch their computer when a program underlines a spelling/grammer mistake? I hate that so much. MS Word pisses me off the most.

  36. TheHackZone5 Avatar

    @chili24137 i no man but he is the one who searched for the tutorials !

  37. chili24137 Avatar

    @TheHackZone5 lol dude, this isn't bucky, roflllllll

  38. TheHackZone5 Avatar

    nice tutorial man…bucky you are AWESOME for doing this .. i mean getting new tutorials

Leave a Reply

Your email address will not be published. Required fields are marked *