From: Alex Balfour on
On 03/07/2010 01:44, Larry Serflaten wrote:
> "Alex Balfour"<AlexBalfour(a)stokepoges.plus.com> wrote
>
>> creates the file CSV text file eurofxref.csv as required. It looks
>> perfect when opened in a text editor (PSPad) but, when I try to use it,
>> VB6 keeps telling me that I have read beyond the end of the file,
>> presumably because there is no final Ctrl+Z.
>>
>> I can solve this problem by opening the file in PSPad, making a minor
>> edit, undoing the edit and saving the file, but clearly that is a
>> temporary kluge.
>
>
> A file, is a file, is a file, is a file....
>
> VB can open any file. They are just so many bytes on a disk.
> How you treat them is what matters.
>
> If they throw garbage at you, wear a raincoat.
>
> 'Input past the end of the file' sounds like you might be using Line Input.
> Have you tried opening the file for Binary access and using Get to fill
> a Byte array? Once in memory you can slice and dice it to your hearts
> content....
>
> How are you reading the file, that causes the error?
>
> LFS
>
>

Larry,

I was using Line Input, but I adopted your suggestion and there is still
a problem. Using the code:

FL = FileLen("eurofxref.csv")
ReDim mybytes(1 To FL)

FN = FreeFile
Open "eurofxref.csv" For Binary As #FN
Get #FN, , mybytes
Close #FN

there is no error message but nothing gets transferred into the byte
array mybytes. However, if I first open the file eurofxref.csv in PSPad,
make a minor change, undo it and save the file, then the above code
works fine.

This is driving me crazy!

AlexB

From: Bob Butler on

"Alex Balfour" <AlexBalfour(a)stokepoges.plus.com> wrote in message
news:i0ltu0$uvk$1(a)news.eternal-september.org...
<cut>
> The line
>
> RetVal = Shell("unzip.exe" & " " & "eurofxref.zip", 0)
>
> creates the file CSV text file eurofxref.csv as required. It looks perfect
> when opened in a text editor (PSPad) but, when I try to use it, VB6 keeps
> telling me that I have read beyond the end of the file, presumably because
> there is no final Ctrl+Z.

Is your code to read the file immediately after the line above? If so,
Shell runs asynchronously so you may be trying to read the file before it
has been created. You need to wait for unzip to finish; search for "shell
and wait" for lots of examples of how to do that.

From: Henning on

"Alex Balfour" <AlexBalfour(a)stokepoges.plus.com> skrev i meddelandet
news:i0ltu0$uvk$1(a)news.eternal-september.org...
> On 02/07/2010 20:41, Kevin Provance wrote:
>>
>> "Alex Balfour"<AlexBalfour(a)stokepoges.plus.com> wrote in message
>> news:i0l9k8$5b6$1(a)news.eternal-september.org...
>> :
>> : Any suggestions anyone? All I need is a simple unzip capability.
>>
>> Info-ZIP. Google it.
>>
>>
>>
>
> Hi Kevin,
>
> Your suggestion works like a dream up to a point.
>
> The line
>
> RetVal = Shell("unzip.exe" & " " & "eurofxref.zip", 0)
>
> creates the file CSV text file eurofxref.csv as required. It looks perfect
> when opened in a text editor (PSPad) but, when I try to use it, VB6 keeps
> telling me that I have read beyond the end of the file, presumably because
> there is no final Ctrl+Z.
>
> I can solve this problem by opening the file in PSPad, making a minor
> edit, undoing the edit and saving the file, but clearly that is a
> temporary kluge.
>
> I tried changing the above to:
>
> RetVal = Shell("unzip.exe" & " -aa " & "eurofxref.zip", 0)
>
> but the problem persists.
>
> Do I need to change the command line options or what?
>
> By the way, the CSV file produced by the European Central Bank is unusual.
> It contains several line feed characters and no carriage returns.
>
> AlexB
>
>

Or maybe it starts with a Ctrl+Z? Get shuldn't care for Ctrl+Z.

/Henning


From: Alex Balfour on
On 03/07/2010 14:50, Bob Butler wrote:
>
> "Alex Balfour"<AlexBalfour(a)stokepoges.plus.com> wrote in message
> news:i0ltu0$uvk$1(a)news.eternal-september.org...
> <cut>
>> The line
>>
>> RetVal = Shell("unzip.exe"& " "& "eurofxref.zip", 0)
>>
>> creates the file CSV text file eurofxref.csv as required. It looks perfect
>> when opened in a text editor (PSPad) but, when I try to use it, VB6 keeps
>> telling me that I have read beyond the end of the file, presumably because
>> there is no final Ctrl+Z.
>
> Is your code to read the file immediately after the line above? If so,
> Shell runs asynchronously so you may be trying to read the file before it
> has been created. You need to wait for unzip to finish; search for "shell
> and wait" for lots of examples of how to do that.
>

Bob,

Eureka! That was the problem. I had set up some code to wait but my
approach was clearly flawed.

My thanks to everyone who offered help. Much appreciated.

AlexB