-
put into binary file
without explaining too much detail as to why (its a long story) I need to be able to do the following in VB6:
1) given a double array full of values, store its exact binary representation in memory as a binary file.
converting to text wont work for me. I am trying to send a file to a colleague for troubleshooting. its an input to a dll and it has some sort of weird numerical error going on. I send a text representation of the array and it does not duplicate the issue. i cant send him the code to generate the error (another long story).
I suspect there is an issue with irrational binary representations of doubles ...
anyone know how to do #1 above?
any help greatly appreciated!
-
Re: put into binary file
You can save the double array directly to disk and load it back.
Example:
Code:
Private Sub Form_Load()
Dim d() As Double
ReDim d(3) As Double
d(0) = 3424: d(1) = 66720: d(2) = 56: d(3) = 99
Dim intFF As Integer: intFF = FreeFile
Open "C:\test.txt" For Binary Access Write As #intFF
Put #intFF, , d
Close #intFF
End Sub
The result is a 32 byte file which is correct since 4 values, 8 bytes each for double data type.
You can then load the file back into the array.
Is this what you mean?
Also, if the dimensions of the array are not known/it is a dynamic array, you will need to write the dimensions of the array to the start of the file so you know how to ReDimension the array back when reading the file.