您好我刚刚开始学习VB,就像它在VS 2015中一样。我正在使用Bryon Newsome的书Beginning Visual Basic 2015进行练习。我无法从发布商论坛或发布商处获得任何帮助。我设法在之前的练习中修复了这种类型的错误,但无法通过以下方式查看任何内容以进行修复。
以下是第214至215页的代码:
Public Class Form1
Private Sub btn2Buttons_Click(sender As Object,
e As EventArgs) Handles btn2Buttons.Click
If MessageBox.Show("Your Internet connection will now be closed.",
"Network Notification", MessageBoxButtons.OKCancel,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) _
= Windows.Forms.DialogResult.OK Then
lblResults.Text = "OK Clicked"
'Call some method here
Else
lblResults.Text = "Cancel Clicked"
'Call some method here
End If
End Sub
End Class
以下是两条错误消息:
Severity Code Description Project File Line
Error BC30456 'OKCancel' is not a member of 'MessageBoxButtons'. MessageBoxButtons E:\Document\Programing\VB\MessageBoxButtons\MessageBoxButtons\Form1.vb 5
Severity Code Description Project File Line
Error BC30456 'Forms' is not a member of 'Windows'. MessageBoxButtons E:\Document\Programing\VB\MessageBoxButtons\MessageBoxButtons\Form1.vb 7
有一个标签:lblResults,文本属性没有点击
有一个按钮:btn2buttons,文本属性为2个按钮。
答案 0 :(得分:0)
If MessageBox.Show("Your Internet connection will now be closed.",
"Network Notification", System.Windows.Forms.MessageBoxButtons.OKCancel,
System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.OK Then
lblResults.Text = "OK Clicked"
'Call some method here
Else
lblResults.Text = "Cancel Clicked"
'Call some method here
End If