VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Trim all those EXTRA spaces

by Brian Gillham (7 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

VB forgot to add a Function strip out all those LEADING, TRAILING and EXTRA spaces in ONE Function.
I have seen many attempts at doing this but think mine does it in the least amount of code.
Note: = literal SPACE

Inputs
String eg:Stripall
Code Returns
Stripall

Rate Trim all those EXTRA spaces

Public Function TrimALL(ByVal TextIN As String) As String
 TrimALL = Trim(TextIN)
 While InStr(TrimALL, String(2, " ")) > 0
 TrimALL = Replace(TrimALL, String(2, " "), " ")
 Wend
End Function

Download this snippet    Add to My Saved Code

Trim all those EXTRA spaces Comments

No comments have been posted about Trim all those EXTRA spaces. Why not be the first to post a comment about Trim all those EXTRA spaces.

Post your comment

Subject:
Message:
0/1000 characters