From: Boris P. on
In Java there is a method called "readInt" for a data input stream.

I thought that I could simply port this method to VB6 by using

dim l& 'I guess that a Java integer is a long in VB6
Get #m_IFile, , l

But that does not really return the same value as I get in Java.
Can anybody help?
From: Boris P. on
I found the problem now...

dim l&
Get #m_iFile, , l

Dim s$
s = "&H" & Hex(l)

"s" is now close to value in Java.

But there is a problem which I don't understand.

The values in s are "reversed".

They read
DDCCBBAA

while they should read
AABBCCDD

Does anybody know what I'm doing wrong?
From: Boris P. on
Here is how it works for me as it should, but it looks so damn ugly...
Is there a way to make this quicker (in aspects of speed) and more
beautiful?

Public Function readInt() As Long

Dim b(3) As Byte

Get #m_iFile, , b()

Dim sThis$
sThis = "&H"

Dim l&
For l = 0 To UBound(b)
sThis = sThis & Hex(b(l))
Next l

readInt = CLng(sThis)

End Function
From: Larry Serflaten on

"Boris P." <bpnotvalid(a)nospamhotmail.com> wrote
> Here is how it works for me as it should, but it looks so damn ugly...
> Is there a way to make this quicker (in aspects of speed) and more
> beautiful?

Exactly what is in the file (How many bytes per value, and what are
the byte values) and what does Java's readInt return for those bytes?

LFS


From: Boris P. on
Hi Larry,

I don't know yet what exactely is in the file, but I need to import it.

Java behaves just like my own function which I have posted in my last
submission (the function "readInt" in VB6 format).