Posted By

brunozepelini on 07/29/10


Tagged

VBNet Arraylist


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

brunozepelini


White space/Empty String trim function, for Arraylist class


 / Published in: VB.NET
 

I don\\'t know if exist a easier way to do this. For me, works fine. =)

  1. Sub ClearArray(ByVal lst As ArrayList)
  2. Dim flag As Boolean = False
  3.  
  4. For x As Integer = 0 To lst.Count - 1
  5. If x > lst.Count - 1 Then
  6. flag = True
  7. End If
  8.  
  9. If x = lst.Count Then
  10. Exit For
  11. End If
  12.  
  13. If String.IsNullOrEmpty(lst(x)) Or Regex.IsMatch(lst(x), "[\s]+") Then
  14. lst.RemoveAt(x)
  15. If Not flag Then
  16. x = x - 1
  17. Else
  18. x = x + 1
  19. End If
  20. End If
  21. Next
  22. End Sub

Report this snippet  

You need to login to post a comment.