Click here to Skip to main content
14,580,625 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,

I am getting problem in msgbox.
I display error in msgbox.When I disply error in msgbox , it opens new window for that and in results my form can be accessed at that time. I dont want to be accessed my form when it shows error.

Please help...


Thank You
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

MsgBox function will always open new window you will need an other way to display error message if no user input is required
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi
to get the desired results 2 ways r there
1. you can create unmanaged message box
2. show the messagebox in another thread

here i've shown the 2nd one

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            'do some work
            'for instance I'm intentionally creating an exception
            Throw New Exception("test error message")
        Catch ex As Exception
            Dim t As New Threading.Thread(New Threading.ParameterizedThreadStart(AddressOf shoMsg))
            t.Start(ex)
        End Try
        
    End Sub

    Private Sub shoMsg(ex As Exception)
        MessageBox.Show(ex.Message)
    End Sub
End Class
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

If you are using a custom dialog to show the error, then use the ShowDialog() call instead of the Show() call to display it. That will make your form inaccessible while the error is being displayed. If you use the built in MessageBox object, then it automatically will be modal.
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

you can simply do it see

when you want to open a msgbox show your msgbox form by showdialog


on formload of msgbox put your error msg by passing it from the last form

on okbtn click close this form
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100