string - help needed

bigboyron

New member
Joined
Jun 11, 2005
Messages
1
Programming Experience
Beginner
i made a code
VB.NET:
         If uni.Text = "01" Then
             myCSV = coursecode(0).ToString.Split(",")
             Me.ListBox15.Items.AddRange(myCSV)
             For ii = 1 To 135
                 Me.ListBox15.Items.Remove("")
             Next
         End If
and i need to repeat it 15 times -
if uni.text = "02" then
..... coursecode(1)
if uni.text = "03" then
..... coursecode(2)
and etc.
i would only like to use the code once instead of 15 times so i wrote a string.
VB.NET:
[b] Dim myCSV() As String
		Dim i As Integer
		Dim ii As Integer
		Dim s As String = "01|02|03|04|05|06"
		Dim my() As String
		my = s.Split("|")
		If uni.Text = my(i) Then
			myCSV = coursecode(my(i) - 1).ToString.Split(",")
			Me.ListBox15.Items.AddRange(myCSV)
			For ii = 1 To 135
				Me.ListBox15.Items.Remove("")
			Next
		End If[/b]
but only "01" works and the rest dont - can anyone tell me where i went wrong? thanks in advance
 
It is not very clear what you wanted, therefore it is hard for me to give you the sample code. However, it seems only '01' works because you didn't put
If uni.Text = my(i) Then

within For..Next block. Try this:
If uni.Text = my(i) Then
For x As Integer = 0 To Ubound(my) - 1
myCSV = coursecode(my(i) - 1).ToString.Split(",")
Me.ListBox15.Items.AddRange(myCSV)
For ii = 1 To 135
Me.ListBox15.Items.Remove("")
Next
Next
End If
 
Back
Top