VBScript Skip blank spaces

Greeting,

I have the following code in my vbscript which split the txt file. Right now it only split by a blank space how to skip if there are more than one blank spaces in between?

Do While Not f.AtEndOfStream
 
   line = f.Readline
  columns = split(line, " ")
  strColumn1 = columns(0)
  strColumn2 = columns(1)
  strColumn3 = columns(2)

Thanks.
mrongAsked:
Who is Participating?
 
Bill PrewCommented:
Try this:

line = f.Readline
Do While Instr(line, "  ") > 0
   line = Replace(line, "  ", " ")
Loop
columns = split(line, " ")
strColumn1 = columns(0)
strColumn2 = columns(1)
strColumn3 = columns(2)

Open in new window

~bp
0
 
mrongAuthor Commented:
changed to the followings and works.

Do While Instr(strLine, "  ") > 0
         strLine = Replace(strLine, "  ", " ")
         Loop
      arrNames = Split(strLine, " ")
        strColumn1 = arrNames(0)
        strColumn2 = arrNames(1)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.