Solved

throw error msgs when two appointments are at the same time

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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 …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

630 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