list i have:

School,campus,adminno,modulecode,modulegroup
    SEG AMK 101427Y EG3902 EG3902-G1
    SEG AMK 101427Y EGS650 EGS650-G1
    SEG AMK 103852S EG3901 EG3901-G1
    SEG AMK 103852S EG3904 EG3904-G1
    SEG AMK 103852S EGS104 EGS104-G1
    SEG AMK 103852S EGS650 EGS650-G1
    SEG AMK 106581C EG3901 EG3901-G1
    SEG AMK 106581C EG3902 EG3902-G1
    SEG AMK 111713M EG3901 EG3901-G1
    SEG AMK 111713M EG3902 EG3902-G1

again, in access database.

and i have a paperslist (exam paper list):

paperno.,school,paperid,papertitle, numberofstudents,duration,modulecodes
    1   SEG-AMK EG1832  Mechanics and Materials         286 1.5 EG3901                          
    2   SEG-AMK EG1833  Electrical Principles           375 1.5 EG1833  EG3904  EG1903                  
    3   SEG-AMK EG1835.1 Engineering Mathematics (1)    456 1.5 EG1835  EG1001                      
    4   SEG-AMK EG1835.2 Engineering Mathematics (2)    363 1.5 EG1907  EG1681  EG1951
from table1, column 3 & 4, is the students registered for these module

then i have paper1 which involved module EG3901 & in paper 2, EG1833, EG3904, EG1903
then from table1, student 103852S is registered under modules EG3901 and EG3904

it is then said that paper 1 and paper 2 there is a conflict(common student).

later on in scheduling the exam time table, these 2 papers shall not be sheduled under the same time slot.

i got no idea how to go about writing the codes.
i can't say if adminNo=ModuleCode as they are not equal.

anyone please help me with this.

Here's a way based on the code I gave you before. I set it up to use a dictionary with the module code as the key and a list of the admin nos. as the value:

    'Declare this class level
    Dim StudentList As New Dictionary(Of String, List(Of String))

    For Each row As DataRow In dt.Rows
        Dim TempItem As New ListViewItem(row.Item(3).ToString)
        If Not ListView1.Items.ContainsKey(TempItem.Text) Then
            'Add new dictionary entry using ModuleCode as the key
            StudentList.Add(row.Item(3).ToString, New List(Of String))
            'Add the adminno the the list of student for this modulecode.
            StudentList(row.Item(3).ToString).Add(row.Item(2).ToString)
            TempItem.SubItems.AddRange(New String() {row.Item(4).ToString.Substring(7), "1", row.Item(2).ToString})
            TempItem.Name = TempItem.Text
            ListView1.Items.Add(TempItem)
        Else
            'Since the module code already has an entry just add the adminno to the list.
            StudentList(row.Item(3).ToString).Add(row.Item(2).ToString)
            TempItem = ListView1.Items.Find(TempItem.Text, False)(0)
            TempItem.SubItems(2).Text = (Integer.Parse(TempItem.SubItems(2).Text) + 1).ToString
            TempItem.SubItems(3).Text &= row.Item(2).ToString & ","
        End If
    Next
    DataGridView1.DataSource = dt
End Sub

Then a Boolean function that returns true if there are no common students between 2 modules would look something like this:

Private Function CheckStudent(modulecode1 As String, modulecode2 As String) As Boolean
    CheckStudent = True
    For Each student As String In StudentList(modulecode1)
        If StudentList(modulecode2).Contains(student) Then
            Return False
        End If
    Next
End Function

A simple conditional to see if they can be scheduled at the same time:

If CheckStudent(Module1,Module2) = True then

thanks so much for taking you time to help me with this.

but what if i wanna do in DGV.
Listview looks complicated to me, kind of hard for me to understand.

desired output should look like:

Conflictingpaper       no.ofstudent      adminno
1 : 3                   2                111411H
                                         23982B
Be a part of the DaniWeb community

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