尝试显示消息框时,重载分辨率失败

时间:2013-09-28 23:08:35

标签: vb.net vb.net-2010 messagebox

我在使用以下代码在VB 2010中编写问题。

 Public Sub about(ByVal sender As System.Object, ByVal e As System.EventArgs)
    MessageBox.Show("Omega Management System © Shelby Taylor 2013 ******@gmail.com", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

我将这个代码放在一个模块中,我将其用作通用“持有者”,以便在我的程序的幕后保存一些数据库连接。我想创建一个messagebox子程序,如果用户单击一个按钮,它将显示我的联系信息,在这种情况下,我将调用此过程并显示消息框。

我收到以下错误。

Error   1   Overload resolution failed because no accessible 'Show' can be called without a narrowing conversion:
'Public Shared Function Show(owner As System.Windows.Forms.IWin32Window, text As String, caption As String) As System.Windows.Forms.DialogResult': Argument matching parameter 'owner' narrows from 'String' to 'System.Windows.Forms.IWin32Window'.
'Public Shared Function Show(owner As System.Windows.Forms.IWin32Window, text As String, caption As String) As System.Windows.Forms.DialogResult': Argument matching parameter 'text' narrows from 'System.Windows.Forms.MessageBoxButtons' to 'String'.
'Public Shared Function Show(owner As System.Windows.Forms.IWin32Window, text As String, caption As String) As System.Windows.Forms.DialogResult': Argument matching parameter 'caption' narrows from 'System.Windows.Forms.MessageBoxIcon' to 'String'.
'Public Shared Function Show(text As String, caption As String, buttons As System.Windows.Forms.MessageBoxButtons) As System.Windows.Forms.DialogResult': Argument matching parameter 'caption' narrows from 'System.Windows.Forms.MessageBoxButtons' to 'String'.
'Public Shared Function Show(text As String, caption As String, buttons As System.Windows.Forms.MessageBoxButtons) As System.Windows.Forms.DialogResult': Argument matching parameter 'buttons' narrows from 'System.Windows.Forms.MessageBoxIcon' to 'System.Windows.Forms.MessageBoxButtons'. M:\oms\omega_managment_system\WindowsApplication1\globalStructures.vb   21  9   Omega Managment System

我不明白发生了什么。有人可以解释一下问题是什么,以及如何解决它?

谢谢。

1 个答案:

答案 0 :(得分:0)

错误消息告诉所有人:

Public Shared Function Show(text As String, caption As String, _
buttons As System.Windows.Forms.MessageBoxButtons) ...
Argument matching parameter 'caption' narrows from 
  'System.Windows.Forms.MessageBoxButtons' to 'String'.

您必须遵循这些格式。第二个arg应该是一个字符串(标题),但是你传递了按钮信息。有多种方法可以调用(所以多个msgs),但你需要遵循其中一个