Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB6 Input command problem with commas

Posted on 2006-10-25
4
Medium Priority
?
1,433 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
  • 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 200 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

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

963 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