Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


VBScript Skip blank spaces

Posted on 2012-09-04
Medium Priority
Last Modified: 2013-09-25

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)

Question by:mrong
LVL 59

Accepted Solution

Bill Prew earned 2000 total points
ID: 38365600
Try this:

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

Open in new window


Author Comment

ID: 39520798
changed to the followings and works.

Do While Instr(strLine, "  ") > 0
         strLine = Replace(strLine, "  ", " ")
      arrNames = Split(strLine, " ")
        strColumn1 = arrNames(0)
        strColumn2 = arrNames(1)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question