FindString Help !!!

dojoGirlaurora

New member
Joined
Apr 13, 2005
Messages
2
Programming Experience
5-10
I'm writing a schedule application where the output is displayed in two
list boxes, one for appointment information and one for time. I'm using FindString as part of a Boolean function used to prevent duplicate appointment times from being displayed in the time listBox. But instead of searching through all of the items in the listBox, FindString only seems to be searching through the first item, so that if the duplicate is the first item in the listBox, it works fine, but otherwise it allows the duplicate value to be entered. Please help.

Here's the code in question:


'If TimeTaken is True
If TimeTaken(dtmTakenTest) = True Then

'display Warning
MessageBox.Show(Text:="You already have an appointment at this time ", _
caption:="Cannot Add Appointment")

'select invalid input
dtpTime.Focus()
dtpTime.Select()

ElseIf TimeTaken(dtmTakenTest) = False Then 'time is valid

'assign user input to variable
dtmAppointmentTime = dtmTakenTest

'Call AppointmentDisplay Sub procedure
AppointmentDisplay(dtmAppointmentTime, strAppointment)


Private Function TimeTaken(ByRef dtmTakenTest As Date) As Boolean
Dim itemIndex As Integer


'assign new input to dtmTakenTest
dtmTakenTest = dtpTime.Text

If (itemIndex = lstTimes.FindString(dtmTakenTest.ToString("hh:mm tt")) = True) Then

Return True

ElseIf (itemIndex = lstTimes.FindString(dtmTakenTest.ToString("hh:mm tt")) = False) Then
'new input is not a duplicate

Return False

End If

End Function 'End Function TimeTaken
 
Back
Top