3 Replies - 478 Views - Last Post: 07 December 2012 - 06:12 PM Rate Topic: -----

#1 Prohhmetheus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-December 12

VB 2010 Exam Program Error

Posted 06 December 2012 - 02:31 PM

I'm working on an assignment that asks me to create an exam application. I'm supposed to store the correct answers in an array, which I did. I also need to display whether each answer was correct or incorrect in the list box. I've been trying to find what's wrong with my code but I can't.

I'm getting the error:
"Error when trying to run the project: could not load file or assembly "Filename" or one of it's dependencies. The given assembly name or codebase was invalid.(Exception from HRESULT:0x80131047)

Public Class Form1
    Dim Answers() = {"B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A"}
    Dim intScore As Integer
    Private Sub btnScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScore.Click
        Try
            If txtAns01.Text = Answers(0) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#1 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#1 incorrect")
            End If
            If Me.txtAns2.Text = Answers(1) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#2 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#2 incorrect")
            End If
            If Me.txtAns3.Text = Answers(2) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#3 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#3 incorrect")
            End If
            If Me.txtAns4.Text = Answers(3) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#4 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#4 incorrect")
            End If
            If Me.txtAns5.Text = Answers(4) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#5 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#5 incorrect")
            End If
            If Me.txtAns6.Text = Answers(5) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#6 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#6 incorrect")
            End If
            If Me.txtAns7.Text = Answers(6) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#7 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#7 incorrect")
            End If
            If Me.txtAns8.Text = Answers(7) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#8 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#8 incorrect")
            End If
            If Me.txtAns9.Text = Answers(8) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#9 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#9 incorrect")
            End If
            If Me.txtAns10.Text = Answers(9) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#10 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#10 incorrect")
            End If
            If Me.txtAns11.Text = Answers(10) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#11 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#11 incorrect")
            End If
            If Me.txtAns12.Text = Answers(11) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#12 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#12 incorrect")
            End If
            If Me.txtAns13.Text = Answers(12) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#13 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#13 incorrect")
            End If
            If Me.txtAns14.Text = Answers(13) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#14 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#14 incorrect")
            End If
            If Me.txtAns15.Text = Answers(14) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#15 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#15 incorrect")
            End If
            If Me.txtAns16.Text = Answers(15) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#16 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#16 incorrect")
            End If
            If Me.txtAns17.Text = Answers(16) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#17 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#17 incorrect")
            End If
            If Me.txtAns18.Text = Answers(17) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#18 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#18 incorrect")
            End If
            If Me.txtAns19.Text = Answers(18) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#19 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#19 incorrect")
            End If
            If Me.txtAns20.Text = Answers(19) Then
                intScore += 1
                ResultsForm.lstAnswers.Items.Add("#20 correct")
            Else
                ResultsForm.lstAnswers.Items.Add("#20 incorrect")
            End If
            If intScore >= 15 Then
                ResultsForm.lstAnswers.Items.Add("You Passed")
            Else
                ResultsForm.lstAnswers.Items.Add("You failed. Please retake the test.")
            End If
            ResultsForm.Show()
        Catch
            MessageBox.Show("Please only use the answers A, B, C, or D")
        End Try
    End Sub
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        txtAns01.Text = ""
        txtAns2.Text = ""
        txtAns3.Text = ""
        txtAns4.Text = ""
        txtAns5.Text = ""
        txtAns6.Text = ""
        txtAns7.Text = ""
        txtAns8.Text = ""
        txtAns9.Text = ""
        txtAns10.Text = ""
        txtAns11.Text = ""
        txtAns12.Text = ""
        txtAns13.Text = ""
        txtAns14.Text = ""
        txtAns15.Text = ""
        txtAns16.Text = ""
        txtAns17.Text = ""
        txtAns18.Text = ""
        txtAns19.Text = ""
        txtAns20.Text = ""
    End Sub
End Class



I can remove my code as soon as the problem is solved. I'm not sure if it's an issue with the file or my code.

Is This A Good Question/Topic? 0
  • +

Replies To: VB 2010 Exam Program Error

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,478
  • Joined: 16-March 11

Re: VB 2010 Exam Program Error

Posted 06 December 2012 - 02:41 PM

Did you change the name of the project solution? Just save, close down visual studio, reopen your project solution and it should be okay. Had this error this morning after I changed a visual studio solution file name. Let me know if that helps.
Was This Post Helpful? 0
  • +
  • -

#3 Prohhmetheus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-December 12

Re: VB 2010 Exam Program Error

Posted 06 December 2012 - 03:31 PM

That worked, thanks again for the help trevster :).
Was This Post Helpful? 0
  • +
  • -

#4 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,478
  • Joined: 16-March 11

Re: VB 2010 Exam Program Error

Posted 07 December 2012 - 06:12 PM

No problem man!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1