Justin,
I would consider doing this in the database itself with correlated outer
joins if possible.
Presumable you really want to know a list of employees with the dates they
are missing, correct?
If you "needed" to do it client side, I would probably use DataTables
instead of arrays...
Here is one possibility:
Dim ds As New DataSet("Justin Emlay")
' define the tables needed
Dim employees As New DataTable("empl oyees")
employees.Colum ns.Add("id", GetType(Integer ))
employees.Colum ns.Add("name", GetType(String) )
employees.Prima ryKey = New DataColumn() {employees.Colu mns("id")}
ds.Tables.Add(e mployees)
Dim dates As New DataTable("date s")
dates.Columns.A dd("id", GetType(Integer ))
dates.Columns.A dd("name", GetType(String) )
dates.PrimaryKe y = New DataColumn() {dates.Columns( "id")}
ds.Tables.Add(d ates)
Dim timeSheets As New DataTable("time Sheets")
timeSheets.Colu mns.Add("employ eeId", GetType(Integer ))
timeSheets.Colu mns.Add("dateId ", GetType(Integer ))
timeSheets.Prim aryKey = New DataColumn()
{timeSheets.Col umns("employeeI d"), timeSheets.Colu mns("dateId")}
ds.Tables.Add(t imeSheets)
Dim missing As New DataTable("miss ing")
missing.Columns .Add("employeeI d", GetType(Integer ))
missing.Columns .Add("dateId", GetType(Integer ))
missing.Primary Key = New DataColumn()
{missing.Column s("employeeId") , missing.Columns ("dateId")}
ds.Tables.Add(m issing)
' define relationships between the tables
ds.Relations.Ad d("dateTimeShee ts", dates.Columns(" id"),
timeSheets.Colu mns("dateId"))
ds.Relations.Ad d("employeeTime Sheets", employees.Colum ns("id"),
timeSheets.Colu mns("employeeId "))
ds.Relations.Ad d("dateMissing" , dates.Columns(" id"),
missing.Columns ("dateId"))
ds.Relations.Ad d("employeeMiss ing", employees.Colum ns("id"),
missing.Columns ("employeeId "))
' add some sample data
With employees.Rows
.Add(New Object() {1, "Employee 1"})
.Add(New Object() {2, "Employee 2"})
.Add(New Object() {3, "Employee 3"})
End With
With dates.Rows
.Add(New Object() {1, "Date 1"})
.Add(New Object() {2, "Date 2"})
.Add(New Object() {3, "Date 3"})
.Add(New Object() {4, "Date 4"})
.Add(New Object() {5, "Date 5"})
End With
With timeSheets.Rows
.Add(New Object() {1, 1}) 'Employee 1 - Date 1
.Add(New Object() {1, 2}) 'Employee 1 - Date 2
.Add(New Object() {1, 3}) 'Employee 1 - Date 3
.Add(New Object() {1, 4}) 'Employee 1 - Date 4
.Add(New Object() {1, 5}) 'Employee 1 - Date 5
.Add(New Object() {2, 1}) 'Employee 2 - Date 1
.Add(New Object() {2, 3}) 'Employee 2 - Date 3
.Add(New Object() {2, 4}) 'Employee 2 - Date 4
.Add(New Object() {2, 5}) 'Employee 2 - Date 5
.Add(New Object() {3, 2}) 'Employee 2 - Date 5
.Add(New Object() {3, 5}) 'Employee 2 - Date 5
End With
' find the missing dates for each employee
For Each employee As DataRow In employees.Rows
For Each [date] As DataRow In dates.Rows
Dim keys() As Object = {employee!id, [date]!id}
If Not timeSheets.Rows .Contains(keys) Then
missing.Rows.Ad d(keys)
End If
Next
Next
' display the results
For Each miss As DataRow In missing.Rows
Debug.WriteLine (miss!dateId, miss!employeeId .ToString())
Dim [date] As DataRow = miss.GetParentR ow("dateMissing ")
Dim employee As DataRow = miss.GetParentR ow("employeeMis sing")
Debug.WriteLine ([date]!name, DirectCast(empl oyee!name, String))
Next
Hope this helps
Jay
"Justin Emlay" <NO***********@ Maisto.com> wrote in message
news:Ob******** *****@TK2MSFTNG P11.phx.gbl...
The problem extents a little further. If there is no date then there is
no record. There will always be a date and an employee number as a record
was added to the DB. Each record is a "time sheet". If entered, thats great.
We need to know missing timesheets. I wish there was someway to compair
arrays and output the differences.
ArrayDates() - pre defined what the 10 dates are
Array1() - Unique set of employee numbers
Array2() - Unique set of dates per employee Array1(i)
Compair ArrayDates() with Array2() and give me the difference.
"John" <I_*********@mi crosoft.com> wrote in message
news:ex******** ******@TK2MSFTN GP12.phx.gbl... Have you thought about creating a checksum?
For I = 1 To 10
' parse data into line (ie: first line would be "Employee 1 -
Date 1")
Do Until Right$(line, I) = I
Missing = Missing + 2^(I - 1)
I = I + 1 'double execute
Loop
' (This is a loop because there might be consecutive missing
records)
' save data at right spot, if data was missing, the counter has
been updated to reflect that, and ' data will still be stored at
the index corresponding to the Index
Next I
' Now you have a Missing variable, which is unique for all occasions. I
guess you don't need explanations how to read the variable again and
figure out the missing links... if you do, post here again, and I'll try to
help. BTW: this is a solution which doesn't require too much memory (only 1
integer which holds the checksum). If you'd rather have a less processor
consumtive way (you will need to read this variable again), then you
might consider just storing the numbers of all the missing lines into an
array, which might be a bit faster. Not much though, and it will take loads of
extra memory.
I'm guessing the distinguishing between dates etc. won't be as easy as
described (ie: the lines won't just end with 'date 1', but with a real
date), but you can always load the supposedly correct dates into an
array and then examine if the input matches array(I).
Hope this helps and wasn't too fuzzy, I'm not great at explaining
things...
John
---
Outgoing mail is certified Virus Free by AVG 6.0
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.716 / Virus Database: 472 - Release Date: 5-7-04