473,379 Members | 1,423 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,379 software developers and data experts.

Check for Duplicate Appointment Times

I have a simple application that takes user input by text and time
selected by date time picker. It displays the appt description in one
list box and the time in another list box. I need a simple function
that checks the times for duplicates. I want to check for a duplicate
before it writes to the
listbox by returning a boolean (true/false) value I'm new to this so
any help would
be appreciated.

Thanks

Nov 13 '06 #1
7 1608
Geo,

At least for me it is not clear what you want, be aware that you seldom will
find a real equality in time values give by the date time picker because it
is (not real) accurate in milliseconds, therefore you should have to take a
time or a date part.

Cor

"geo039" <ca************@hotmail.comschreef in bericht
news:11**********************@b28g2000cwb.googlegr oups.com...
>I have a simple application that takes user input by text and time
selected by date time picker. It displays the appt description in one
list box and the time in another list box. I need a simple function
that checks the times for duplicates. I want to check for a duplicate
before it writes to the
listbox by returning a boolean (true/false) value I'm new to this so
any help would
be appreciated.

Thanks

Nov 14 '06 #2
I'm only checking for hours and minutes not date or seconds. I'm
wondering if something like this would work but my only confusion lies
in the fact that we are dealing with date/time. It's not an integer or
a double?? Is it ByVal As Date, I don't know

Public Function DoesTimeExistInListBox(ByVal sometime As ???)
As Boolean
Dim bExistsInListbox As Boolean = False
For Each strItem As String In ListBox1.Items
If strItem = sometime Then
bExistsInListbox = True
Exit For
End If
Next

Return bExistsInListbox
End Function

Nov 14 '06 #3
DateTime

Cor

"geo039" <ca************@hotmail.comschreef in bericht
news:11*********************@k70g2000cwa.googlegro ups.com...
I'm only checking for hours and minutes not date or seconds. I'm
wondering if something like this would work but my only confusion lies
in the fact that we are dealing with date/time. It's not an integer or
a double?? Is it ByVal As Date, I don't know

Public Function DoesTimeExistInListBox(ByVal sometime As ???)
As Boolean
Dim bExistsInListbox As Boolean = False
For Each strItem As String In ListBox1.Items
If strItem = sometime Then
bExistsInListbox = True
Exit For
End If
Next

Return bExistsInListbox
End Function

Nov 14 '06 #4
Right now I have this but it's not finding duplicates, I think there's
a problem with the function? Any Suggestions?

Dim Time As Boolean
Time = TimeTaken(Me.dtmTime.Value.ToShortDateString)
If Time Then
MessageBox.Show("You already have an appointment at
this time")
Else
'display appointment in Listbox
lstApptResults.Items.Add(txtAppointment.Text)
txtAppointment.Clear() 'clear appointment from TextBox
txtAppointment.Focus() 'transfer focus to TextBox
'display appointment time in Listbox
lstTimeResults.Items.Add(Me.dtmTime.Value.ToShortT imeString)
End If
End If
End Sub 'btnAddAppt_Click
'function to check if an appointment time already exists in listbox

Public Function TimeTaken(ByVal ApptTime As DateTime) As Boolean
Dim DuplicateTime As Boolean = False
'loop that checks listed times for duplicates
For Each strItem As String In lstTimeResults.Items
If strItem = ApptTime Then
DuplicateTime = True
Exit For
End If
Next
Return DuplicateTime
End Function 'TimeTaken

Nov 15 '06 #5
For Each strItem As String In lstTimeResults.Items
If strItem = ApptTime Then
Could it be because you are comparing a string to a datetime? Perhaps
you should convert strItem to a datetime before running the comparison.
(or ApptTime to a string)

Thanks,

Seth Rowe
geo039 wrote:
Right now I have this but it's not finding duplicates, I think there's
a problem with the function? Any Suggestions?

Dim Time As Boolean
Time = TimeTaken(Me.dtmTime.Value.ToShortDateString)
If Time Then
MessageBox.Show("You already have an appointment at
this time")
Else
'display appointment in Listbox
lstApptResults.Items.Add(txtAppointment.Text)
txtAppointment.Clear() 'clear appointment from TextBox
txtAppointment.Focus() 'transfer focus to TextBox
'display appointment time in Listbox
lstTimeResults.Items.Add(Me.dtmTime.Value.ToShortT imeString)
End If
End If
End Sub 'btnAddAppt_Click
'function to check if an appointment time already exists in listbox

Public Function TimeTaken(ByVal ApptTime As DateTime) As Boolean
Dim DuplicateTime As Boolean = False
'loop that checks listed times for duplicates
For Each strItem As String In lstTimeResults.Items
If strItem = ApptTime Then
DuplicateTime = True
Exit For
End If
Next
Return DuplicateTime
End Function 'TimeTaken
Nov 15 '06 #6
Geo,

Have a look in the findstringexact for the listbox.

http://lab.msdn.microsoft.com/search...indstringexact

I hope this helps,

Cor

"geo039" <ca************@hotmail.comschreef in bericht
news:11*********************@e3g2000cwe.googlegrou ps.com...
Right now I have this but it's not finding duplicates, I think there's
a problem with the function? Any Suggestions?

Dim Time As Boolean
Time = TimeTaken(Me.dtmTime.Value.ToShortDateString)
If Time Then
MessageBox.Show("You already have an appointment at
this time")
Else
'display appointment in Listbox
lstApptResults.Items.Add(txtAppointment.Text)
txtAppointment.Clear() 'clear appointment from TextBox
txtAppointment.Focus() 'transfer focus to TextBox
'display appointment time in Listbox
lstTimeResults.Items.Add(Me.dtmTime.Value.ToShortT imeString)
End If
End If
End Sub 'btnAddAppt_Click
'function to check if an appointment time already exists in listbox

Public Function TimeTaken(ByVal ApptTime As DateTime) As Boolean
Dim DuplicateTime As Boolean = False
'loop that checks listed times for duplicates
For Each strItem As String In lstTimeResults.Items
If strItem = ApptTime Then
DuplicateTime = True
Exit For
End If
Next
Return DuplicateTime
End Function 'TimeTaken

Nov 15 '06 #7
I tried this

For Each strItem As DateTime In lstTimeResults.Items
If strItem = ApptTime Then

doesn't work either, i'm off to make sense of this exactstringmatch
business

Nov 15 '06 #8

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

Similar topics

3
by: Sam | last post by:
My db looks after the hiring and lending of equipment, the form which books out equipment hired prints a signout sheet and automatically inserts an appointment into outlook advising the operator on...
5
by: Notgiven | last post by:
You want to check scheduling conflicts and you have a record like: appointments(table): apptID beginningDate endingDate beginningTime endingTime It's easy enough to check if a time is...
1
by: Colin Possamai | last post by:
I have a table with 14 days and appointment times. The days are numbered 0 to 13 (fortnight worth). I have a query (FortnightQuotesAppointments) that adds now() to day number to get the date of...
13
by: YoVoltron | last post by:
I am just starting this "appointment book" java program and would appreciate some basis direction. I do not expect anyone to write the code for me but i would like opinions on how to best handle the...
2
by: zabartcc | last post by:
Hey guys. I’m having a problem and I need help desperately. I am writing an appointment scheduler and have run into an issue. I have an access database to store all the appointment information. ...
3
by: geo039 | last post by:
I have a simple application that takes user input by text and time selected by date time picker. It displays the appt description in one list box and the time in another list box. I need a simple...
4
geo039
by: geo039 | last post by:
I tried to write a simple application that takes user input by text and time selected by date time picker. It displays the appt description in one list box and the time in another list box. I wrote...
2
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain...
2
by: Ranma13 | last post by:
Hello, I have a duplicate record check written in VB for a check in/check out database. Here's the pseudocode, written for the BeforeUpdate property on the form: If DCount(search for records with...
0
by: =?Utf-8?B?UmljaGFyZCBLaXJieQ==?= | last post by:
Hi, I have W Mobile 2003 SE v 4.21 on my O2 xda IIs PDA. Then I travel to a new time zone I would like to change the time on my PDA but each time it asks if you want to change the appoinment times...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.