473,800 Members | 2,641 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!
Nov 22 '05 #1
0 1219

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

Similar topics

0
1468
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
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
2056
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...
3
1628
by: Fred Nelson | last post by:
I'm devloping a Web Application in VB.NET. In my web.config file I have specified that untrapped errors are to be sent to the page "errorpage.aspx". This is working fine - if an untrapped error occurs the application is indeed routed to this page. On this page I would like to determine the cause of the error and either log it in a file or send it to me via e-mail. I am able to determine the page that sent me there from the URL...
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
1500
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
2121
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
9690
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
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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
7576
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
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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.