Solved

throw error msgs when two appointments are at the same time

Posted on 2007-03-27
1
211 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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