Solved

How to clear a list box in VB

Posted on 2007-12-05
5
3,218 Views
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?
0
Comment
Question by:ashblynn02
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 20411258
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
 
LVL 23

Expert Comment

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

Author Comment

by:ashblynn02
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
        ListBox.Items.clear()
        ListBox.clear()
        txtguess.Text = ""
        listguess.Text = ""
        lblinfo.Text = ""
        btnguess.Enabled = True
        Randomize()
    End Sub

Open in new window

0
 
LVL 23

Accepted Solution

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

ListBox.Items.Clear()

and remove ListBox.clear()
0
 
LVL 5

Expert Comment

by:23637269
ID: 21087671

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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