Guys, thanks for replying. Here is my code:
I have 2 listboxes list1 & list2:
Dim g As Int32 = 0
Dim h As Int32 = 0
Dim iCountI As Integer
iCountI = list2.Items.Count - 1
Dim iCountCl As Integer
iCountCl = list1.Items.Count - 1
Dim str1 As String = " "
str1 = list2.Items(iCountI - 1).Value.Substring(0)
If list1.SelectedIndex < iCountCl Then
h = list1.SelectedIndex + 1
End If
If list2.SelectedIndex < iCountI Then
g = list2.SelectedIndex + 1
End If
If list1.SelectedItem.Value.Substring(0, 1) <> "T" And list2.SelectedItem.Value.Substring(0, 1) <> "C" And list1.Items(h).Value.Substring(0, 1) <> "C" And list2.Items(g).Value.Substring(0, 1) <> "T" Then
Dim c1 As Int32 = 0
Dim i1 As Int32 = 0
Dim var1 As String = list1.SelectedItem.Value.Substring(1)
Dim var2 As String = list2.SelectedItem.Value.Substring(1)
Dim tvar1 As String = list2.Items(g).Value.Substring(0, 1)
If list1.SelectedIndex <> -1 And lbItems.SelectedIndex <> -1 And list1.SelectedIndex <= list1.Items.Count - 1 And list2.SelectedIndex <= list2.Items.Count - 1
Then
For c1 = list1.SelectedIndex + 1 To list1.Items.Count - 1
For i1 = list2.SelectedIndex + 1 To list2.Items.Count - 1
If c1 > 0 And c1 <= list1.Items.Count - 1 And i1 > 0 And i1 <= list2.Items.Count - 1 Then
If list1.Items(c1).Value.Substring(1) = list2.Items(i1).Value.Substring(1) Then
somefunction()
Exit Sub
End If
End If
Next i1
Next c1
End If
End If
End If
''''var1,var2 & tvar1 are used for debugging purpose
I need to iterate from the two lists. The lists are arranged as:
Day-LIST1 Topic-LIST2
--------- ----------
Day1 topic1
-topic1 -Day1
-topic3 -Day4
Day2 topic2
Day3 -Day3
-topic3 topic3
-topic2 -Day1
Day4 -Day3
-topic1
I am attaching & dettaching days(LIST1) with topic(LIST2) & vice versa using the above code. Say if i select Day3 from List1 & topic2 from List2 and call somefunction() to de-attach, it removes topic2 from List1 & Day3 from List2 only against the selected value-set and not elsewhere. But again if i select Day3 from List1 but topic1 from List2, it is expected not to do anything as there is no matching pair in the subset,but it is removing Day3 from List2. I need to stop this. Also as shown in the code,the Ist character of any DAY begins with 'C' and the Ist character of any TOPIC begins with 'T' . I have been using it above for few validations check.
The datatypes are varchar.
I hope its clear now. I need to validate the dettaching thing.
|