Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Blanks from Array 2

Status
Not open for further replies.

johnny45

Technical User
Nov 8, 2006
136
CA
Hello,
I'm using the following code to get data from a user form...I would like to remove the blanks or spaces from the created array...The data comes from a multy line text box, so I must first remove the CR...but I'm not sure how to remove any blanks or spaces that might be in the array

Code:
    Dim txt As String
    Dim x As Variant
    Dim i As Long
    txt = Replace(upctxt, Chr(13), " ")
    x = VBA.split(txt, " ")
    For i = 0 To UBound(x)
       MsgBox x(i)
    Next i
 
With CreateObject("vbscript.regexp")
.Pattern = "[\s]+$"
.Global = True
.MultiLine = True
x = Split(.Replace(upctxt, ""), vbLf)
End With

For i = 0 To UBound(x)
MsgBox x(i)
Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top