Solved

VB6 Input command problem with commas

Posted on 2006-10-25
4
1,400 Views
Last Modified: 2007-11-27
I have written a VB6 application that reads in a fixed length text file and populates a MS SQL Server database with the information.  Below is the command I use to read the file:

        Open Projects_File For Input As #1
        Do Until EOF(1)
            Input #1, mWork_String1
 
            ...(process the records)
           
            DoEvents
        Loop
        Close #1

Periodically, the input text file has a comma in one of the fields and when that happens, everything from the comma on is ignored - not read in.  I don't understand why that happens in a fixed length file.  I can see commas causing a problem in a .cscv input file, but this is a fixed length file.

Anyway, the mWork_String1 variable never receives any data after the comma and that means I am dropping data.

This is causing problems with importing of the data.  Does anyone have any idea about how to fix this problem?  Any work-around?

Thanks
0
Comment
Question by:EYoung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17804895
Instead of:

    Input #1, mWork_String1

Try:

    Line Input #1, mWork_String1

(assuming you have one "record" per line)
0
 
LVL 7

Author Comment

by:EYoung
ID: 17804932
There is one line per record.  Never heard of that option.  What does that do?  (Thanks)
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 50 total points
ID: 17804993
"Line Input" reads in the entire line and places it into the "mWork_String1" variable.
0
 
LVL 7

Author Comment

by:EYoung
ID: 17805322
Perfect.  Thanks for the quick help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

732 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