473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Determining where date overlapping is occuring

I am creating a custom control that contains a list view with dates and times. I need to make sure that times do not overlap. I would like the control to determine if the overlap is occuring with the starting time or with the ending time and offer the user an adjusted time entry. Below is the code I'm using currently to check the date and time. How would I modify it to detect where the overlap is occuring.

Public Sub Add(ByVal StartTime As DateTime, ByVal EndTime As DateTime)
If Me.CheckTimes(StartTime, EndTime) = -1 Then
MsgBox("The starting time cannot occur before the ending time!")
Exit Sub
ElseIf Me.CheckTimes(StartTime, EndTime) = 0 Then
StartTime = Me.LatestTime(StartTime, EndTime)
If MsgBox("You are attempting to insert an overlapping time." & vbCrLf & " The starting time has been adjusted to " & StartTime & vbCrLf & "Continue inserting this time?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.Add(StartTime, EndTime)
End If
Exit Sub
End If
Dim myItem As New ListViewItem
myItem.Text = StartTime
myItem.SubItems.Add(EndTime)
myItem.SubItems.Add(FormatNumber(DateDiff(DateInte rval.Minute, StartTime, EndTime) / 60, 2))
Me.Times.Items.Add(myItem)
TotalHours.Text = FormatNumber(Me.CalculateHours) & " hrs."
End Sub

Private Function CheckTimes(ByVal StartTime as datetime, ByVal EndTime as datetime) As Integer
If StartTime > EndTime Then
Return -1
End If
For Each item As ListViewItem In Me.Times.Items
Dim testEnd As DateTime = item.SubItems(1).Text
Dim testStart As DateTime = item.Text
If StartTime < testEnd And EndTime > testStart Then
Return 0
End If
Next
Return 1
End Function
Thanks for any input!
Jul 21 '05 #1
0 1445

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Baker | last post by:
HI; I have a table where the user is entering data which shows scheduling for member of teams. One problem we have encountered is that sometimes the inputter (is this a word) puts in dates for...
6
by: HateSpam | last post by:
I am trying to write a function that determines how many hours there are until a certain date/time that depends on what today's date/time is. Basically, how many hours from now until the next...
3
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not...
0
by: Chris Q. | last post by:
I am creating a custom control that contains a list view with dates and times. I need to make sure that times do not overlap. I would like the control to determine if the overlap is occuring with the...
2
by: David | last post by:
We've developed a seismic-data processing app in VB.NET 1.1 which runs on XP Pro using SQL2K. Like all seismic data apps, it deals with HUGE amounts of binary data (we use NTFS sparse "flat...
4
by: gzaxar | last post by:
Hi to all in forum. It is my first post here. I am quite new in MsAccess programming. Here is a problem which i am facing to. I want to keep records of employees CV's. More specifically i want...
1
by: FrankEBailey | last post by:
Hi, I have a limited number of ad slots on my website, let's say there are 5. I have lots of people wanting to advertise in those slots, let's say there are 100. They each join the queue for an...
2
by: monadel | last post by:
I have a problem with checking the overlapping date. Basically I am developing a database using MS Access (VB scripts) and SQL queries. I have 2 tables which are empTable and empLeaveTable. In a...
4
by: Nathan Sokalski | last post by:
When determining whether a String can be converted to a DateTime, you can use the IsDate() method. However, I would also like to know whether the string is a date, a time, or both a date and a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.