Remove all whitespace from string

Submitted by:Jhon Brain

Date added:04 February, 2013

Category:Visual Basic

This removes every instance of a space in the given string returning the new string as a string for Visual Basic

Tags: remove space

Code Snippet:

Public Function remove_whitespace(str As String) As String
Dim current_char As Variant
Dim new_str As String
For i = 1 To Len(str)
current_char = Mid$(str, i, 1)
If current_char = " " Then
current_char = ""
End If
new_str = new_str & current_char
Next i
remove_whitespace = new_str
End Function