none
vb.net how to auto close message box / Error message box that popup RRS feed

  • Question

  • hi,

    anyone know how to auto close message box / error message box . or change the property of error message box  title  or  auto close error message box ?


    Thursday, November 15, 2018 10:47 AM

All replies

  • There is a C# NuGet package containing a auto-close MessageBox.

    Source code and link to NuGet package.

    Here are two examples using the above in VB.NET, note the timeout property.

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim toBeOrNotToBeQuestion = AutoClosingMessageBox.
                    Factory(showMethod:=Function(caption, buttons)
                                            Return MessageBox.Show(Me, "To be or not to be?", caption, buttons, MessageBoxIcon.Question)
                                        End Function, caption:="The question")
            If DialogResult.Yes = toBeOrNotToBeQuestion.Show(timeout:=2500, buttons:=MessageBoxButtons.YesNo, defaultResult:=DialogResult.No) Then
                MessageBox.Show("Yes")
            Else
                MessageBox.Show("No")
            End If
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            AutoClosingMessageBox.
                Factory(showMethod:=Function(caption, buttons)
                                        Return MessageBox.Show(Me, "To be or not to be?",
                                                               caption, buttons, MessageBoxIcon.Exclamation)
                                    End Function, caption:="Alert").Show(timeout:=1000, buttons:=MessageBoxButtons.OK)
        End Sub
    
    
    End Class


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, November 15, 2018 11:47 AM
    Moderator