How to clear a list box in VB

How do you clear a list box in Visual Basic 2005?

I have a button reset that clears everything but I can't get it to clear the list box? how would I do that?
ashblynn02Asked:
Who is Participating?
 
Ashish PatelConnect With a Mentor Commented:
Replace change the case of clear() to Clear(), like this

ListBox.Items.Clear()

and remove ListBox.clear()
0
 
TimCotteeHead of Software ServicesCommented:
Listbox.Clear()

Or ListBox.Items.Clear()

Can't remember which it is off the top of my head but it is one of these two.
0
 
Ashish PatelCommented:
if you are using vb.net 2005 then listbox.items.clear() is the syntax
0
 
ashblynn02Author Commented:
neither of those are working.... :(
listbox.clear: Error- 'clear' is not a member of 'System.Windows.Forms.ListBox'.
listbox.items.clear(): Error- Reference to a non-shared member requires an object reference.
 Private Sub Btnreset_enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnreset.Click
        ListBox.Items.clear()
        ListBox.clear()
        txtguess.Text = ""
        listguess.Text = ""
        lblinfo.Text = ""
        btnguess.Enabled = True
        Randomize()
    End Sub

Open in new window

0
 
23637269Commented:

  With List1
    .Clear
    .AddItem "Test1"
    .AddItem "Test2"
  End With
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.