473,788 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(S tartTime, EndTime) = -1 Then
MsgBox("The starting time cannot occur before the ending time!")
Exit Sub
ElseIf Me.CheckTimes(S tartTime, EndTime) = 0 Then
StartTime = Me.LatestTime(S tartTime, 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.Yes No) = MsgBoxResult.Ye s Then
Me.Add(StartTim e, EndTime)
End If
Exit Sub
End If
Dim myItem As New ListViewItem
myItem.Text = StartTime
myItem.SubItems .Add(EndTime)
myItem.SubItems .Add(FormatNumb er(DateDiff(Dat eInterval.Minut e, StartTime, EndTime) / 60, 2))
Me.Times.Items. Add(myItem)
TotalHours.Text = FormatNumber(Me .CalculateHours ) & " hrs."
End Sub

Private Function CheckTimes(ByVa l 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 1467

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

Similar topics

2
4799
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 an individual that overlap, creating all sorts of problems. One record is entered for each scheduled event (each one is a day in length or more), so that an individual will have multiple events on the table. For the purposes of this question,...
6
2055
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 time that it is 8am on Monday. I've found the dateadd, hour, and weekday functions, but I can't seem to get it straight in my head how to use them in this case.
3
11584
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 overlap existing records from the same table. I had this all working some time ago, but recently when I have gone back to do more testing, part of these validations no longer work. While there have been changes to the code in the meantime, I cannot...
0
1218
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 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...
2
1495
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 files") ... a typical user will have a 20 Terabyte raid array. During a particular operation that reads, formats and exports these files, we've noticed that sometimes it runs rather slowly... like it might take 12 hours to finish exporting the same...
4
4741
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 to keep the data regarding experience but i need to avoid time overlapping. I use the following tables - among others- EmployeeTb(means employee's table, Edu_ExperTb (means educational experience table) and Prof_ExperTb (means all other experience...
1
1499
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 ad slot on a first- come, first-served basis. I have been trying to find a way to determine the active date for a queued item. For the first five items in the queue it's easy, it's just the expiry date of the item in a live slot that expires...
2
3841
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 form I have put all the employee data on a label. There are another text boxes that user must put in when the an emploee wants to start leave and end leave. When user click on submit button it will check wheter the empoyee already submitted a leave...
4
2119
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 time. Is there any simple way to do this without using manual pattern matching? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.