473,386 Members | 1,803 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.

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 only need to check hours and minutes not date or seconds. I'm
new to this so any help would be appreciated.

Thanks

Nov 14 '06 #1
3 1309
Hello,

I am going to assume a Windows form.

You basically have to loop through the listbox. Examine each entry by setting it's selected value to true. Read the value of the selected row and then validate it.

Sample:
Dim i As Integer
Dim bolAddNew as Boolean

For i = 0 To Me.ListBox1.Items.Count
Me.ListBox1.SelectedIndex = i
If Me.ListBox1.SelectedValue = txtTime.Text Then
bolAddNew = True
Exit For
Else
BolAddNew = False
End If
Next

If boilAddNew Then
'Add New Time
Else
'Optional: Display MSGBOX
End If

"geo039" <ca************@hotmail.comwrote in message news:11*********************@f16g2000cwb.googlegro ups.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 only need to check hours and minutes not date or seconds. I'm
new to this so any help would be appreciated.

Thanks
Nov 14 '06 #2
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 14 '06 #3
If you step through the program, what value are you passing to TimeTaken?
It looks as though you are passing a date and not time.

"geo039" <ca************@hotmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.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 #4

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...
7
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...
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. ...
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: 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: 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
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...
0
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,...
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.