Discussion Locked

Delimiters in VB

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am new to Visual Basic and am trying to read a sequential file. Can you change the delimiter of a string to something other than quotes?

5 replies

by result

The Write # statement writes data in a consistent and fixed format, which ensures the data can be read in any locale. If this is not the behavior you want, you can use Print #, which will write data to a sequential file as it would appear on the screen. For example:

Open "C:\MyTest.txt" For Output As #1

Write #1, "Test String with Write"
Print #1, "Test String with Print"

Close #1

If you were to open up MyTest.txt in Notepad, the output would be:

"Test String with Write"
Test String with Print

by Former member

Thanks for the assistance and sorry I did not reply sooner.. I guess I was not clear. I can write/print the file BUT I need to get rid of the quotes around the string (" ") and the commas (,) between fields as I need to use this file in anotherapplication that does not accept " (quotes) and , (commas) in fields. Thanks for responding...

by awilliams3

Review the following Microsoft Knowledge Base article:

XL: Procedure to Export Text File with Comma AND Quote Delimiter
http://support.microsoft.com/support/kb/articles/Q123/1/83.asp?LN=EN-US&SD=gn&FR=0

Though the article is written for Excelthe code itself demonstrates the importing of a text file with multiple delimiters. With the exception of depositing the data to a worksheet this code will work in Visual Basic, changing the destination of the imported text to a control, a databasetable, or even a worksheet, etc.

by Former member

Thanks for responding... I did see the article I have not tried that method.. I was just hoping that there was a simpler solution. (i.e. A command/agruement that would allow you to write to a file without using special characters..)

by Former member

This question was closed by the author

This discussion is closed to new replies.