Solved

VB6 Input command problem with commas

Posted on 2006-10-25
4
1,393 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 85

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 85

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Title # Comments Views Activity
JSON Response and request in VB6 application 11 586
Adding to a VBA? 6 78
Problem to With line 4 63
VB 6 error 5 in windows 10 but not in XP 7 63
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

829 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