By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,097 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,097 IT Pros & Developers. It's quick & easy.

Using a listbox value

P: 4
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!
Mar 20 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.