Link to home
Start Free TrialLog in
Avatar of nschulz777
nschulz777

asked on

Treat Consecutive Delimiters as One

I'm using the following code to import a space
delimited file. Works fine if there is only
one space. How can I import files with a varied
number of spaces?
Line Input #s1, strField
   ary1 = Split(strField, " ")
outFields = UBound(ary1)
str1 = ary1(0)
str2 = ary1(1)
str3 = ary1(2)
ASKER CERTIFIED SOLUTION
Avatar of crazyman
crazyman
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anthony Perkins
Add a reference to Microsoft VBScript Regular Expressions

Line Input #s1, strField

Set m_RegExp = New VBScript_RegExp_55.RegExp
With m_RegExp
    .Pattern = " +"    'Look for more than one blank
    .Global = True
    strField = .Replace(strField, " ")
End With
Set m_RegExp = Nothing

ary1 = Split(strField, " ")
outFields = UBound(ary1)
str1 = ary1(0)
str2 = ary1(1)
str3 = ary1(2)

Anthony
Avatar of nschulz777
nschulz777

ASKER

Took me awhile to have time to try your code,
works perfectly,
Thanks