473,699 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a listbox value

4 New Member
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 ConfirmDestinat ion '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.EventArg s) Handles Button23.Click
Dim newItem As String = TextBox1.Text
items.Add(newIt em) '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.I tems.Add(newIte m)


TextBox1.Text = ""

If frm1 Is Nothing OrElse frm1.IsDisposed Then
frm1 = New ConfirmDestinat ion
frm1.ListBox2.I tems.AddRange(i tems.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.I tems.Add(Item1)
End If

If newItem = "OSTERLEY" Then
Dim Item2 As String = "TW74NB"
postcodeitem.Ad d(Item2)
'If Form2 exists then add the item to it's listbox
If frm1 IsNot Nothing AndAlso Not frm1.IsDisposed Then frm1.ListBox3.I tems.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
0 1353

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

Similar topics

17
3118
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP) Me.lboxRP.SetSelected(newRPindex, True) When the last line executes, I get an error message:
6
2708
by: A P | last post by:
Hi! I have seen some techniques like this on the web. Currently, I'm using Combo box which values came from database table. One disadvantage is when the combo box have lots of values, users are complaining since you cannot use keyboard to search the value that is needed. Hope you might help me. regards, Me
9
6999
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
19
4101
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
2
2912
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However, currently the code is such that with each selection there is a postback. We want to avoid it using filter and javascript. I am not using ADO.NET but adodbc and no datagrids or datasets (please don't tell me that i should as my boss clearly doesn't want...
4
2454
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item, what do I need to do in order to return the "option value" of the control? Moe !--- returned value of the control
4
1854
by: collie | last post by:
HI, I need to populate 2 listboxes from a db. When the page loads then the first listbox needs to be populated and based on selection from that listbox the second listbox needs to be populated accordingly with the matching items. However, my boss doesn't want the page to do a postback once an item from the first listbox is selected. also, he doesn't want to use ado.net but classic ado. He wants to use jscript. I am writing my code in...
3
2380
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores in the database is the top item in the listbox. How can I get the listbox to add all the bit values to be stored and also come out properly when viewed later? Example:
1
4026
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set. when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
5
2845
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that is what the ListBox uses for its display. Correct?
0
8691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7755
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6536
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2351
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.