Question Working with ListBoxes in VS2005

will10000

New member
Joined
Jun 23, 2008
Messages
2
Programming Experience
Beginner
Hello,

I have a problem using ListBoxes in VS2005

I am making a program which will display 10 randomly generated denary figures to the end user.

These figures will be displayed in a listbox, ten rows down.

Next to the list box will be 10 textboxes; where the end user will enter the 10 binary alternatives to the denary figures.

I have
1) Generated the 10 numbers; into a listbox

2) Converted the numbers into binary as well; for comparison at the end of the quiz

The problem is that:
I don't know how to compair the items in the listbox, with the items in the textbox.

I have managed to do this:

If TextBox1.Text = ListBox1.SelectedItem Then
MessageBox.Show("Correct")
End If


But as you can imagine; this is no way to run a quiz..

This method requires the end user to check that he has entered the correct item each time they fill in the binary alternative.

I am asking whether there is a method to take the items out of the listbox and put them into an array..?

Or maybe (even better) to say something like:

If ... Listbox1.Item1 = Textbox1.Text Then ...

Basically; I need to be able to refer to an individual item in the listbox.. like an index

I know that in an array, one says: strDemo(0)

and that would refer to the first item in the array.

That's the end of the question.

Here's some code used to generate the listbox contents:
Randomize()
Dim intA As Integer
For intA = 1 To 10
ListBox1.Items.Add(Int(Rnd() * 10))
Next


-----------------------------------

Any help would be great since i'm so stuck

Thanks- Will
 
The ListBox1.Items is a collection of objects. You do not need to move this into an array. You can use ListBox1.Items.Item(0) to reference the first item in the ListBox for instance. Hope this helps.
 
Back
Top