White space/Empty String trim function, for Arraylist class


/ Published in: VB.NET
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.