Login Register






Tutorial .NET Remove Blanks filter_list
Author
Message
.NET Remove Blanks #1
Code:
'//Remove Blanks Dim i As Long i = 0 '' remove anything that looks like a blank While i < ListBox1.Items.Count If "" = Trim(ListBox1.Items(i).ToString) Then ListBox1.Items.RemoveAt(i) Else i = 1 + i End If End While '//

Enjoy.

Reply

RE: .NET Remove Blanks #2
This is more what the for loop should be used for instead as it's conditionally based off of an incremented variable. I use a while loop usually if I have to base something majorly off of a condition itself, this is more of an iteration...

And if you are having to remove blanks from items added to a ListBox, that's just wasted time. If you have to do something like this, you then should realize that what you're doing is probably poor.

Prevention is better than having to deal with it after the fact.
-- cxS

[ Haskell/.NET/C/C++ - Software Engineer ]

Reply