我一直在我的代码行中出现此错误,我似乎无法修复它。 这是我的代码:
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)
noQuestions
之前的第二个左括号。
答案 0 :(得分:0)
这是声明数组的正确形式:
Dim Array(2) As String
所以在你的情况下,它将是:
Dim responses(((noOfQuestions - 1) + 1) - 1) As String