Reputation:
I have simple portion of program which troubles error: VB MsgBox YesNo not declared.
Am using Visual Studio Express 2012 and Windows 7 if it matters.
VbYesNo is not declared. 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
Upvotes: 0
Views: 2661
Reputation: 1
If MsgBox("Are You Sure ?", vbYesNo, "Yes") = MsgBoxResult.Yes Then
MsgBox("Yes")
Else
MsgBox("No")
End If
Upvotes: 0
Reputation: 35328
You have a typo:
userchoice = MsgBox("Did you mean to enter A?", vbYesNno, "Yes")
Notice the "Nn". It should be vbYesNo
Upvotes: 2