Solved

throw error msgs when two appointments are at the same time

Posted on 2007-03-27
1
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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