Solved

throw error msgs when two appointments are at the same time

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code conversion from excel vba to visual basic for visual studio 5 49
DataGridView Events ? 3 45
Modal Popup Extender control 1 19
Footer for each row on Gridview 2 21
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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