Solved

throw error msgs when two appointments are at the same time

Posted on 2007-03-27
1
203 Views
Last Modified: 2010-04-23
Hello experts,

                     I need to create an application in VB .Net where the user will enter the reason to their appointment in a textbox and the time from a combo box. Upon entering the info and selecting a time, they enter these information through a button click event. I have two listbox where the first one stores the reason for the appointment and the second one stores the time. Now, I don't want them to enter two appointments at the same time. If they do so, I want to throw an error message saying "The appointment at this time already exists. Any help??

This is what I tried so far:

Under button1_Click event
{
     lstAppointment.Items.Add(txtAppointment.Text)
     lsttime.Items.Add(cboTimeInput.SelectedValue)
}

But i don't know know how would I check to throw an error message if they have two appointments at the same time.
0
Comment
Question by:siddhuoops
1 Comment
 
LVL 11

Accepted Solution

by:
Babycorn-Starfish earned 500 total points
ID: 18804695
Hi there,

you can try searching the Items property of the listbox by using the contains method. In this case if it contains the item you don't want it to be added and a message appears:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       'see if the item is already listed
        If TimeList.Items.Contains(TimesCombo.SelectedItem) Then
            MessageBox.Show("Some kind of error message")            
        Else
            TimeList.Items.Add(TimesCombo.SelectedItem)
            'other stuff added
        End If

hope this helps
    End Sub
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now