Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:58:30+00:00 2026-06-12T15:58:30+00:00

I have a VB.NET (2010) project that contains a generic list, and I’m trying

  • 0

I have a VB.NET (2010) project that contains a generic list, and I’m trying to figure out how to remove any “empty” items from the list. When I say “empty”, I mean any item that does not contain any actual characters (but it may contain any amount of whitespace, or no whitespace at all).

For example, let’s say this is my list…

    Dim MyList As New List(Of String)

    MyList.Add("a")
    MyList.Add("")
    MyList.Add("b")
    MyList.Add(" ")
    MyList.Add("c")
    MyList.Add("      ")
    MyList.Add("d")

I need it so that if I did a count on that list, it would return 4 items, instead of 7. For example…

    Dim ListCount As Integer = MyList.Count
    MessageBox.Show(ListCount) ' Should show "4"

It would be nice if there was something like…

    MyList.RemoveEmpty

Anyways… I’ve been searching Google for a solution to this for the past few hours, but haven’t been able to turn up anything so far. So… any ideas?

BTW, I’m targeting the .NET 2.0 framework for this project.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:58:31+00:00Added an answer on June 12, 2026 at 3:58 pm

    You can use List.RemoveAll

    MyList.RemoveAll(Function(str) String.IsNullOrWhiteSpace(str))
    

    If you don’t use at least .NET 4, you can’t use String.IsNullOrWhiteSpace. Then you can implement the method yourself:

    Public Shared Function IsNullOrWhiteSpace(value As String) As Boolean
        If value Is Nothing Then
            Return True
        End If
        For i As Integer = 0 To value.Length - 1
            If Not Char.IsWhiteSpace(value(i)) Then
                Return False
            End If
        Next
        Return True
    End Function
    

    Note that Char.IsWhiteSpace is there since 1.1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB.NET 2010 project that contains a lot of resources (which I
I have a .NET project in VS 2010 that has grown to consist of
I have a unit test project in Visual Studio 2010 (.NET 4) that utilizes
I have a vb.net (visual studio 2010) project that is version controlled with git
all,, I have a project that is built in VB.Net 2010 and WPF 4.
I have a Visual Studio 2010 project that targets .NET v3.5 (it's a Sharepoint
I have an ASP.NET project that I have created in Visual Studio 2010. So
In Visual Studio 2010 I have an ASP.NET MVC 3 project called blahblah. As
Has anyone migrated a VB6 project to .Net with Visual Studio 2010? I have
I have installed VB.NET express 2010 version and I am trying to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.