1

我在使用以下代码编写 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

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

我收到以下错误。

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

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

谢谢你。

4

1 回答 1

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'.

您必须遵循这些格式。第二个参数应该是一个字符串(标题),但您正在传递按钮信息。可以通过多种方式调用它(因此有多个消息),但您需要遵循其中一种

于 2013-09-28T23:19:57.837 回答