Search Tools Links Login

Squeeze


Visual Basic 6, or VB Classic

Removes extra spaces from given string. eg. Squeeze("^^too^^many^^^spaces^^")returns "too^many^spaces". NB.Read a carat ^ as a single space above. Planet Source code mangles multiple spaces in submitted text.

Original Author: John Bambrick

Inputs

A string, strText.

Assumptions

Doesn't strip tabs, CRLFs or any characters from text EXCEPT char 32.

Returns

A string = strText without spaces and the beginning or end or more than 1 consecutive space within.

Side Effects

None.

Code

Public Function Squeeze (ByVal strText As String) As String
Dim intPos As Integer

intPos = InStr(1, strText, Chr(32) & Chr(32))
If intPos = 0 Then
Squeeze = Trim(strText)
Else
strText = _
Left(strText, intPos - 1) & _
Mid(strText, intPos + 1)
Squeeze = Squeeze(strText)
End If
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 78 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.