I have been working on a program but have been stuck at this section for a couple of hours now. What I am trying to do is have a Listbox with 5 courses in it and the user can select up to 3 classes. Once the classes are selected the choices will be repeated to the user on a Label in the form of a sentence. It has been over a year since I have practiced coding and can't remember. Also don't have the text book that i used when i took visual basic so have no reference either. Here is basicly what I think the code should look like but i get an error
'Courses taken
For i = 0 To (ListBox.Items.Count - 1)
Dim CourseTemp1, CourseTemp2, CourseTemp3 As String
i &= 1
If ListBox.Items(i).Selected = True Then
N &= 1
CourseTemp1 = ListBox.SelectedIndex.ToString(i)
End If
If N = 3 Then
Courses = CourseTemp1 & ", " & CourseTemp2 & " and " & CourseTemp3
varText &= Courses
ElseIf N = 2 Then
Courses = CourseTemp3 & " and " & CourseTemp2
varText &= Courses
ElseIf N = 1 Then
Courses = CourseTemp1
varText &= Courses
LblCourse1.Text = ListBox.SelectedIndex.ToString(1)
End If
Next
any help would be appreciated
'Courses taken
For i = 0 To (ListBox.Items.Count - 1)
Dim CourseTemp1, CourseTemp2, CourseTemp3 As String
i &= 1
If ListBox.Items(i).Selected = True Then
N &= 1
CourseTemp1 = ListBox.SelectedIndex.ToString(i)
End If
If N = 3 Then
Courses = CourseTemp1 & ", " & CourseTemp2 & " and " & CourseTemp3
varText &= Courses
ElseIf N = 2 Then
Courses = CourseTemp3 & " and " & CourseTemp2
varText &= Courses
ElseIf N = 1 Then
Courses = CourseTemp1
varText &= Courses
LblCourse1.Text = ListBox.SelectedIndex.ToString(1)
End If
Next
any help would be appreciated