Listbox

Post new topic   Reply to topic

View previous topic View next topic Go down

Listbox

Post  Robin on Sun Aug 31, 2008 7:20 pm

Well i will try to tell you some basics about the listbox Smile
I will explain it using a textbox.

This is what you will need:

- 1 Form tongue
- 1 ListBox
- 1 TextBox
----------------------------
PART 1
----------------------------
If you double click the form you can add a code that it needs to load on the begin that the program starts, so we will add the items for the listbox there.

To add an item to the list box we need to use

Code:
        ListBox1.Items.Add("Car")
        ListBox1.Items.Add("Plane")
        ListBox1.Items.Add("Bike")


Now your listbox has 3 items; Car, Plane and Bike
----------------------------

PART 2
----------------------------
you need the to add this code:

Code:
        If ListBox1.SelectedItem.Equals("Car") Then
            TextBox1.Text = "You selected the Car"
        ElseIf ListBox1.SelectedItem.Equals("Plane") Then
            TextBox1.Text = "You selected the Plane"
        ElseIf ListBox1.SelectedItem.Equals("Bike") Then
            TextBox1.Text = "You selected the Bike"
        End If


(READ THIS) if you add an item thats called "car" in part 1 and you will add it like "Car" in part 2 it won't work.

BASIC EXPLANATION
So its like this, If the selected item of listbox1 is "Car" then the text in textbox1 is "You selected the Car"

Good Luck =)

DOWNLOAD LINK FOR THE SOURCE : HERE

Robin
Moderator
Moderator

Number of posts: 11
Age: 18
Location: Holland
Registration date: 2008-08-31

View user profile

Back to top Go down

View previous topic View next topic Back to top


Post new topic   Reply to topic
Permissions of this forum:
You cannot reply to topics in this forum