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
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