[英]VB MsgBox vbYesNo not declared
I have simple portion of program which troubles error: VB MsgBox YesNo not declared. 我有简单的程序部分,该错误会引起错误:VB MsgBox是否未声明。
Am using Visual Studio Express 2012 and Windows 7 if it matters. 如果重要,请使用Visual Studio Express 2012和Windows 7。
VbYesNo is not declared. 未声明VbYesNo。 It may be inaccessible due to its protection level. 由于其保护级别,它可能无法访问。
Many thanks trouble not occur in past. 非常感谢过去没有发生过麻烦。
Which program trouble: 哪个程序麻烦:
userchoice = MsgBox("Did you mean to enter A?", vbYesNno, "Yes") ' if yes add, if no subtract
All program: 所有程序:
Public Class MainForm
Public stroperation, strnumber1, strnumber2, strresult As String
Public decnumber1, decnumber2, decresult As Decimal
Public operation, userchoice
Private Sub calculateButton_Click(sender As Object, e As EventArgs) Handles calculateButton.Click
operation = operationTextBox.Text
stroperation = CStr(operation)
strnumber1 = number1TextBox.Text
decnumber1 = CDec(strnumber1)
strnumber2 = number2TextBox.Text
decnumber2 = CDec(strnumber2)
If stroperation = "S" Or stroperation = "s" Then
decresult = decnumber1 - decnumber2
strresult = CStr(decresult)
resultLabel.Text = "Difference: " & strresult
ElseIf stroperation = "A" Or stroperation = "a" Then
decresult = decnumber1 + decnumber2
strresult = CStr(decresult)
resultLabel.Text = "Sum: " & strresult
Else
userchoice = MsgBox("Did you mean to enter A?", vbYesNno, "Yes") ' if yes add, if no subtract
If userchoice = vbYes Then
decresult = decnumber1 + decnumber2
strresult = CStr(decresult)
resultLabel.Text = "Sum: " & strresult
ElseIf userchoice = vbNo Then
decresult = decnumber1 - decnumber2
strresult = CStr(decresult)
resultLabel.Text = "Difference: " & strresult
End If
End If
End Sub
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
You have a typo: 您有错字:
userchoice = MsgBox("Did you mean to enter A?", vbYesNno, "Yes")
Notice the "Nn". 注意“ Nn”。 It should be vbYesNo
应该是vbYesNo
If MsgBox("Are You Sure ?", vbYesNo, "Yes") = MsgBoxResult.Yes Then
MsgBox("Yes")
Else
MsgBox("No")
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.