Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
vb.net Driver License Exam App?
I need to create an app that grades 20 multiple choice choices, with the correct answers stored in an array. The results must be displayed in another form(which questions they missed and got right, and whether they passed or failed. Im not getting any error messages and I cant locate any logic errors please help!
Public Class Form1
Private Sub btnScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScore.Click
Dim strCorrectAnswers() As String = {"B", "D", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A"}
Dim blnInput(19) As Boolean
Dim intCorrect As Integer = 0
Dim intValid As Integer = 0
Dim intCount As Integer = 0
Dim strAnswer(19) As String
Dim frmResults As New frmResult
strAnswer(0) = txtOne.Text
strAnswer(1) = txtTwo.Text
strAnswer(2) = txtThree.Text
strAnswer(3) = txtFour.Text
strAnswer(4) = txtFive.Text
strAnswer(5) = txtSix.Text
strAnswer(6) = txtSeven.Text
strAnswer(7) = txtEight.Text
strAnswer(8) = txtNine.Text
strAnswer(9) = txtTen.Text
strAnswer(10) = txtEleven.Text
strAnswer(11) = txtTwelve.Text
strAnswer(12) = txtThirteen.Text
strAnswer(13) = txtFourteen.Text
strAnswer(14) = txtFifteen.Text
strAnswer(15) = txtSixteen.Text
strAnswer(16) = txtSeventeen.Text
strAnswer(17) = txtEighteen.Text
strAnswer(18) = txtNineteen.Text
strAnswer(19) = txtTwenty.Text
For intCount = 0 To (strCorrectAnswers.Length - 1)
If strAnswer(intCount).ToUpper().Equals("A") Or
strAnswer(intCount).ToUpper().Equals("B") Or
strAnswer(intCount).ToUpper().Equals("C") Or
strAnswer(intCount).ToUpper().Equals("D") Then
If strCorrectAnswers(intCount).Equals(strAnswer(intCount).ToUpper()) Then
intCorrect += 1
blnInput(intCount) = True
intValid = intValid + 1
'Else
' MessageBox.Show("Please enter only A, B, C, or D.")
'End If
End If
End If
Next intCount
If intValid = 20 Then
Dim frmResult As New frmResult
For intCount = 0 To (19)
If (blnInput(intCount) = True) Then
frmResult.lstResult.Items.Add(intCount + 1 & "Correct")
Else
frmResult.lstResult.Items.Add(intCount + 1 & "Answered Incorrectly")
End If
Next intCount
frmResult.lstResult.Items.Add(" ")
frmResult.lstResult.Items.Add("Out of 20 questions, you correctly answered " & intCorrect)
If (intCorrect >= 15) Then
frmResult.lstResult.Items.Add("Passed!")
Else
frmResult.lstResult.Items.Add("Failed.")
End If
End If
End Sub
End Class
sorry please ignore the apostrophe I had commented it out.
3 Answers
- texasmaverickLv 79 years agoFavorite Answer
Your error is in these lines of code
For intCount = 0 To (strCorrectAnswers.Length - 1)
If strAnswer(intCount).ToUpper().Equals("A"… Or
strAnswer(intCount).ToUpper().Equals("B"… Or
strAnswer(intCount).ToUpper().Equals("C"… Or
strAnswer(intCount).ToUpper().Equals("D"… Then
If strCorrectAnswers(intCount).Equals(strAn… Then
intCorrect += 1
blnInput(intCount) = True
intValid = intValid + 1
Change the word "Equals" to the equal sign (=), and remove the left parenthesis at the "A" and remove the periods (...), and ad the underscore (_) as shown below
If strAnswer(intCount).ToUpper = "A" _
Or strAnswer(intCount).ToUpper = "B" _
'and on and on
TexMav
- ¤__¤Lv 49 years ago
'Else
' MessageBox.Show("Please enter only A, B, C, or D.")
'End If
Apostraphes supposed to be there?