Visual Basic Code Snippet - Remove White Spaces

Visual Basic Code Snippet - Remove White Spaces

Visual Basic Code Snippet - Remove White Spaces

(VB) Visual Basic code snippet to remove all white spaces from a string. TrimWhiteSpace strip all white spaces from a given.

Bookmark:

Visual Basic Code Snippet - Remove White Spaces

This .Net Visual Basic code snippet removes all white spaces from a string. White spaces removing done by set of successful matches found by iteratively applying a regular expression pattern to the input string.

Public Function TrimWhiteSpace(ByVal str As String) As String
    Return System.Text.RegularExpressions.Regex.Replace(str, "^\s+", String.Empty)
End Function


VB Keywords Used:

  • Regex
  • Replace

Code Snippet Information:

  • Applies To: .Net, Visual Basic, VB, CLI, HTML, Regular Expression
  • Programming Language : Visual Basic (VB)

External Resources:

Sanjay Chatterjee :: June 01-2011 :: 10:12 AM

Thanks very much. I really needed this one and it was ur code that had helped me. Thanks again. Bye.

Leave a comment