在msgbox中遇到问题 [英] Getting problem in msgbox

查看:108
本文介绍了在msgbox中遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在msgbox中遇到问题.
我在msgbox中显示错误,当我在msgbox中显示错误时,它将为此打开一个新窗口,结果可以在那时访问我的表单.出现错误时,我不想访问我的表单.

请帮忙...


谢谢

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

推荐答案

MsgBox函数将始终打开新窗口,如果不需要用户输入,您将需要其他方式来显示错误消息
MsgBox function will always open new window you will need an other way to display error message if no user input is required


你好
获得2种方法的理想结果
1.您可以创建非托管消息框
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


如果使用自定义对话框显示错误,请使用ShowDialog()调用而不是Show()来显示错误.在显示错误时,这将使您无法访问表单.如果您使用内置的MessageBox对象,那么它将自动成为模态对象.
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.


这篇关于在msgbox中遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆