DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Listbox Value

  1. #1
    Join Date
    Feb 2007
    Posts
    58

    Listbox Value

    Hi. I really need help on how to use a value stored in a listbox.

    I have a form on which it has the following code. This form allows the user to add a value to the textbox which is on this page and then takes the user to the next page:

    Public Class City
    Dim frm1 As ConfirmDestination 'Our instance of form2
    Dim items As New List(Of String) 'Internal collection of items
    Dim streetitem As New List(Of String) 'Internal collection of items
    Dim postcodeitem As New List(Of String) 'Internal collection of items

    Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
    Dim newItem As String = TextBox1.Text
    items.Add(newItem) 'Add new item to our list
    'If Form2 exists then add the item to it's listbox
    If frm1 IsNot Nothing AndAlso Not frm1.IsDisposed Then frm1.ListBox2.Items.Add(newItem)


    TextBox1.Text = ""

    If frm1 Is Nothing OrElse frm1.IsDisposed Then
    frm1 = New ConfirmDestination
    frm1.ListBox2.Items.AddRange(items.ToArray)
    frm1.Show()
    Else
    frm1.Visible = True
    End If

    If newItem = "OSTERLEY" Then
    Dim Item1 As String = "ST MARY'S CRESCENT"
    streetitem.Add(Item1) 'Add new item to our list
    'If Form2 exists then add the item to it's listbox
    If frm1 IsNot Nothing AndAlso Not frm1.IsDisposed Then frm1.ListBox1.Items.Add(Item1)
    End If

    If newItem = "OSTERLEY" Then
    Dim Item2 As String = "TW74NB"
    postcodeitem.Add(Item2)
    'If Form2 exists then add the item to it's listbox
    If frm1 IsNot Nothing AndAlso Not frm1.IsDisposed Then frm1.ListBox3.Items.Add(Item2)
    End If


    End Sub

    Once the user has clicked the NEXT button to go to the next form, there are three listboxes. i want to be able to go through the listbox values and say the following:

    if listbox1 contains ST MARY'S CRESCENT and listbox2 contains OSTERLEY and listbox3 contains TW74NB, then display form A

    HOW do i do this?? Please help!

  2. #2
    Join Date
    Jan 2007
    Posts
    112
    Listbox1.items.contains("Item") will return a true/false value indicating if the list has that string.

Similar Threads

  1. Replies: 5
    Last Post: 03-21-2007, 09:22 AM
  2. Replies: 0
    Last Post: 07-06-2006, 09:47 AM
  3. how to bind the listbox and textbox
    By JenHu in forum .NET
    Replies: 1
    Last Post: 06-12-2006, 07:34 PM
  4. ListBox API
    By Steve J Golem in forum VB Classic
    Replies: 2
    Last Post: 12-09-2000, 11:38 PM
  5. ListBox API
    By Steve J Golem in forum VB Classic
    Replies: 0
    Last Post: 12-09-2000, 10:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center