Using vbTab to create tsv files

G

Guest

I'm attempting to create a tsv file (i.e. equivalent to what Excel produces
when you use the Text (tab delimited) type when saving. I'm trying this...

Dim sw As New System.IO.StreamWriter("c:\test.tsv")
sw.Write("sdfdsf" + vbTab + "dsfsd")
sw.Close()

....but the output of that is gibberish. Anyone how to do this?
 
H

Herfried K. Wagner [MVP]

Rob Oldfield said:
I'm attempting to create a tsv file (i.e. equivalent to what Excel
produces
when you use the Text (tab delimited) type when saving. I'm trying
this...

Dim sw As New System.IO.StreamWriter("c:\test.tsv")
sw.Write("sdfdsf" + vbTab + "dsfsd")
sw.Close()

...but the output of that is gibberish. Anyone how to do this?

This should work. Note that 'StreamWriter' uses UTF-8 by default. Maybe
its the UTF-BOM that is making you think that gibberish got written to the
file. BTW, I recommend to use '&' instead of '+' to concatenate strings.
 
G

Guest

Herfried K. Wagner said:
This should work. Note that 'StreamWriter' uses UTF-8 by default. Maybe
its the UTF-BOM that is making you think that gibberish got written to the
file. BTW, I recommend to use '&' instead of '+' to concatenate strings.

I think you're right about me being confused by 'UTF-BOM/8 thing'. I was
opening the created file in Notepad and it was just displaying a few squares.
I've now tried opening it in Excel and that shows the text correctly.

I think I need to carry on and create the entire file, and then see if the
third party that the file will be delivered to accept it. Now that I know
that it's just a case of 'method of display' I'd hope that I should be OK.

Many thanks.
 
G

GhostInAK

Hello Rob,

You could always do research and know whats going on and perhaps even tailor
the output instead of being a dumb 'tard and releasing crap to a client without
the slightest clue.

-Boo
 
G

Guest

GhostInAK said:
Hello Rob,

You could always do research and know whats going on and perhaps even tailor
the output instead of being a dumb 'tard and releasing crap to a client without
the slightest clue.

-Boo

Well thank you for the input. Feel free to contribute again if you gain the
vaguest clue what it is that you're talking about.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top