0

コードの行内でこのエラーが発生し続けており、修正できないようです。これが私のコードです:

Public Class frmPresentTest

Dim correctAnswer As Double
Dim i As Int32
Dim wrongAnswer As Double
Dim responses As String (((noOfQuestions - 1) + 1) - 1)

Private Sub cmdFinished_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFinished.Click
    Dim str1 As String = "Correct Answer     Your Answer"
    FindChecked(i)
    Dim num2 As Double = 0
    Dim num3 As Integer = (noOfQuestions - 1)
    Dim num1 As Integer = 0
    Do While (num1 <= num3)
        If (responses(num1) <> "*") Then
            If (responses(num1) = test(num1).correctAnswer) Then
                num2 = (num2 + correctAnswer)
            Else
                num2 = (num2 - wrongAnswer)
            End If
        End If
        str1 = New String() {str1 & "            " & test(num1).correctAnswer & "                            " & responses(num1), " "}
        num1 = (num1 + 1)

    Loop
    str1 = str1 & " * indicates that you did answer that question "
    str1 = str1 & " Your score is: " & num2.ToString()
    MsgBox(str1, MsgBoxStyle.OkOnly, "Test Results")
    tookTest = True
    TestGen.My.MyProject.Forms.frmTestGen.Show()
    Me.Hide()

End Sub

Public Sub FindChecked(ByRef i As Int32)

    If (OptA.Checked) Then
        responses(i) = "A"
    ElseIf (optB.Checked) Then
        responses(i) = "B"
    ElseIf (optC.Checked) Then
        responses(i) = "C"
    ElseIf (optD.Checked) Then
        responses(i) = "D"
    Else
        responses(i) = "*"
    End If
End Sub
End Class

このコード行でエラーが発生し続けます。

文字列としての薄暗い回答 (((noOfQuestions - 1) + 1) - 1)

の前の 2 番目の左括弧noQuestions

4

1 に答える 1

0

これは、配列を宣言する正しい形式です。

Dim Array(2) As String 

したがって、あなたの場合は次のようになります。

Dim responses(((noOfQuestions - 1) + 1) - 1) As String
于 2013-10-17T01:15:33.050 に答える