How can I keep a comma from delimiting during import...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thnaks in advance for considering this post. It's probably very simple,
but.....

I have an old VB6 application that allows me to create, save and edit a
"project information file" that is a simple .txt file. I then use that file
to keep the project information current for the multiple AutoCAD drawings
that project requires.

My problem.....several of the items I save are company names (customers).
Many times company names have commas in them. When my VB application imports
a file with a comma in the company name, the comma is interpreted by VB as a
delimiter (spelling) and it splits the name and shifts the balance of the
rest of the information into the next field.

How can I eliminate this from happening??

Thanks again!!
 
Unless you can change the old application I don't think you can logically
distinguish company names with comma's from company names without commas. If
it is possible to change the application that creates the files you could
replace commas in company names by a different character and in the other
application replace the differenct character again with a company

One other trick would be to count the comma's in a row if it is fixed and if
the company name is the only field that can contain a comma and the number
of comma's in a row exceeds the expected number of comma's you know that
there is a comma in the company name. You can then in your application
before the split replace the comma by another character and set the
character back.

There might be several solutions for your problem but we don't know the
specifics.

Gabriel Lozano-Morán
 
My file is not comma delimited. Each piece of data is a new line. So, I
could scan thru each line to find commas and address them as I find them,
correct?

Also, after a little more research, I believe that qoutation marks around
each company name could be a solution, too. Is there a setting for VB to
include quotation marks around data when writing it to a file, or would I
need to hard-code it? I'd have to modify my code in AutoCAD to remove the
quotation marks, though...

Thanks!
 
My file is not comma delimited. Each piece of data is a new line.

In that case where does the splitting exactly happen? Cause I was assuming
that you were trying to import a comma-seperated list.

Gabriel
 
Let's say my .txt file contains:

2005-21
Test Project
Fred's Steel, Inc.
Architects, Inc.

Where the first line is my project number, second line is project name,
third line is my customer and the forth line is the architectural firm. My
VB form has the 4 fields for input. When I start my VB app, I enter the
information as shown above. The .txt file is written correctly. However,
when I use my VB app to re-open the file for editing, "Fred's Steel" is my
customer and "Inc." is the architect's name. If I quit mt app without
saving, the information remains intact.

I did do a quick test and if I put quotations around line 3 and again around
line 4, the information is read correctly by my app.

Thanks, Gabriel!!

Rich.
 
Back
Top