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

これらの形式に従う必要があります。2 番目の引数は文字列 (キャプション) である必要がありますが、ボタン情報を渡しています。それを呼び出す方法は複数ありますが(複数のメッセージがあります)、そのうちの1つに従う必要があります

于 2013-09-28T23:19:57.837 に答える