Solved

How to clear a list box in VB

Posted on 2007-12-05
5
3,227 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
[X]
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
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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