Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How to clear a list box in VB

Posted on 2007-12-05
Last Modified: 2008-03-10
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?
Question by:ashblynn02
LVL 43

Expert Comment

ID: 20411258

Or ListBox.Items.Clear()

Can't remember which it is off the top of my head but it is one of these two.
LVL 23

Expert Comment

by:Ashish Patel
ID: 20411299
if you are using vb.net 2005 then listbox.items.clear() is the syntax

Author Comment

ID: 20411462
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
        txtguess.Text = ""
        listguess.Text = ""
        lblinfo.Text = ""
        btnguess.Enabled = True
    End Sub

Open in new window

LVL 23

Accepted Solution

Ashish Patel earned 500 total points
ID: 20411566
Replace change the case of clear() to Clear(), like this


and remove ListBox.clear()

Expert Comment

ID: 21087671

  With List1
    .AddItem "Test1"
    .AddItem "Test2"
  End With

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question