In VB6, strings are saved as Unicode. In memory, VB6 strings store 4 bytes of overhead plus 2 bytes per character, so your Dim rec As String * 200
statement actually allocates 4 + 200 * 2
bytes of memory, which is 404 bytes. Since VB6 strings and C # strings are Unicode, nothing needs to be changed here.
The Get
command in VB6 extracts bytes from a file. Format Get [#]filenumber, [byte position], variableName
. This will retrieve, however, how many bytes of variableName
are there, starting at the offset byte position
. Byte 1 position is based on VB6.
So now, to translate the code, it should look something like this:
int pos = (rs.Fields["cJobnum"].Value).SubString(6, 4); tempFile.Read(tempBuf, pos - 1, 200);
Note that SubString
based on 0 and Mid
is based on 1, so instead of 7
I used 6
. Also, the offset in the Read
method is based on 0. Get
based on 1 in VB6, so we subtract it.
source share