Hey Guys,
Im not so good at VB.NET , and ive been learning for about 3 months. I would really appreciate it if you guys would help me tackle this problem down.

Well , im helping a school run a Spelling Bee aimed at children in year 7. And to make it fair and unbiased i need an application that can choose randomise a word from the list box then transfer the string to the text box.

So basically something that can pick a random string from the listbox and show it in the textbox1.text property.

Once again , Thanks in advance. I would love it if you guys could help me with this problem. I cant seem to do it with the skills i currently have.

Bye

Have you tried using a Random object?

Perhaps consider generating a random number between 0 and the number of items in the ListBox control. With that number, you can select an item and use that to populate the TextBox.

How can i do that in code. Im not so sure . Sorry buddy. =( Thanks alot though

In the listbox i have the words -
Dinosaur
Space
Astronaughts
Earth
Resolution
Etc

Then i have a label -
Empty

And a button -
Which should include the code of the randomization

Hey , Good News . I was trying to code it. and ive gotten this far.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim r As New Random
        ListBox1.SelectedIndex = r.Next(0, ListBox1.Items.Count - 1)
        TextBox1.Text = ListBox1.Text
    End Sub

Now how can i delete the item i just transfered from the listbox

>how can i delete the item i just transfered from the listbox?

ListBox1.Items.RemoveAt method.

Thanks alot guys - This is my final code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim r As New Random

        ListBox1.SelectedIndex = r.Next(0, ListBox1.Items.Count - 1)
        TextBox1.Text = ListBox1.Text
        ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
    End Sub

Thanks. Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.