Home All Groups Group Topic Archive Search About

Problems reading a text file in VB 6.0

Author
29 Nov 2006 6:52 PM
TeABaG_
I am trying to read a text file with utf-8 encoding in Visual Basic 6.0.  The
problem is that when I use the "Line Input" method, it gets more than what is
really on the first line when I look at the file with a text editor.  The
same code works fine with VBScript, but I converted this code over to Visual
Basic and now I cannot get it to work.  I can send an example file to anyone
if that would help.  I am guessing that perhaps the Line Input method looks
for a NewLine character but utf-8 encoding has these characters differently? 
This was working great in VBScript using the ReadLine method, but now I
cannot get the same thing to work in VB.  Also, I am using VB 6.0, not VB
..NET.  Thanks in advance.

Author
29 Nov 2006 9:11 PM
TeABaG_
I think I have some more info which may be helpful.  Each line in my file
ends with a vbLf (not a vbCrLf or vbNewLine).  So is there a way to use the
Line Input command to read lines by Line feeds, not by new line characters? 
Or would it be better to read the entire file into a string and then sort
that string based up Line feeds?  Not quite sure how to approach this.

Show quoteHide quote
"TeABaG_" wrote:

> I am trying to read a text file with utf-8 encoding in Visual Basic 6.0.  The
> problem is that when I use the "Line Input" method, it gets more than what is
> really on the first line when I look at the file with a text editor.  The
> same code works fine with VBScript, but I converted this code over to Visual
> Basic and now I cannot get it to work.  I can send an example file to anyone
> if that would help.  I am guessing that perhaps the Line Input method looks
> for a NewLine character but utf-8 encoding has these characters differently? 
> This was working great in VBScript using the ReadLine method, but now I
> cannot get the same thing to work in VB.  Also, I am using VB 6.0, not VB
> .NET.  Thanks in advance.
Author
30 Nov 2006 9:30 AM
Michel Posseth [MCP]
Although your question is in the wrong newsgroup  ( this is a VB.Net
newsgroup )

I can answer your question :  

You should use FSO   ( file system object ) in VB6 to do what you want

once i strugled with the same problem and decided to share the solution for
my situation

so look here

http://www.devx.com/tips/Tip/22282

regards

Michel Posseth [MCP] 




Show quoteHide quote
"TeABaG_" wrote:

> I am trying to read a text file with utf-8 encoding in Visual Basic 6.0.  The
> problem is that when I use the "Line Input" method, it gets more than what is
> really on the first line when I look at the file with a text editor.  The
> same code works fine with VBScript, but I converted this code over to Visual
> Basic and now I cannot get it to work.  I can send an example file to anyone
> if that would help.  I am guessing that perhaps the Line Input method looks
> for a NewLine character but utf-8 encoding has these characters differently? 
> This was working great in VBScript using the ReadLine method, but now I
> cannot get the same thing to work in VB.  Also, I am using VB 6.0, not VB
> .NET.  Thanks in advance.