gracea 0 Newbie Poster

I am making an examination software in .One of the features in this s/w is that if a student chooses to skip a question and do the next one , the unattempted question should be immediately displayed in a listbox next to the panel where the questions appear, as a reminder to the student that he has not done those questions.
I have been able to successfully implement it except for one thing that whenever I click on the next button or back button, the unattempted questions reappear, thus making replicate entries in the listbox. my efforts at removing repeated entries are being ‘rewarded’ by an exception ‘Array out of range’or something like that. Plz help. I am giving part of the code below:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
it = ListBox1.Items.Count - 1
i = i - 1
If i = 0 Then
MsgBox("Reached the Beginning")
Button1.Enabled = False
unattqBack() ‘function defined later
j = j - 1
Label7.Text = i.ToString + ") " + dtset2.Tables(0).Rows(i - 1).Item(0)
RadioButton1.Text = "a) " + dtset2.Tables(0).Rows(i - 1).Item(1)
RadioButton2.Text = "b) " + dtset2.Tables(0).Rows(i - 1).Item(2)
RadioButton3.Text = "c) " + dtset2.Tables(0).Rows(i - 1).Item(3)
RadioButton4.Text = "d) " + dtset2.Tables(0).Rows(i - 1).Item(4)

End If
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
End Sub

Sub unattqBack()
Dim num, arr As Integer
arr = ans(j)

If ans(j) = 0 Then
For num = 0 To it
If ListBox1.Items(num) = "Question " & j.ToString Then
ListBox1.Items.Remove("Question " & j.ToString)
End If
ListBox1.Items.Add("Question " & j.ToString)
ListBox1.Items.Remove("Question " & j.ToString)
End If
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.