Re: Reading Binary into array.

Tech-Archive recommends: Fix windows errors by optimizing your registry



First let me apologies for pestering you all... but so far all the advice
has helped my application move along way from theory stage to working
stage...

Asking questions, looking for help in getting problems solved is not
"pestering"... why do you think these newsgroups exist?

I'm wanting to work with a file as binary, but as part of my application
will allow an offset into the file, and the filesize will be a maximum of
64kb, I'm thinking it might be easier to work with the file within an
array (reading it into it) or something, so the offset can just work
within the array rather than reading the file constantly of the drive.

Another possibility, depending on your program's needs, is to simply read
the entire file into a String variable and use the Mid$ function to pull out
sub-strings of text at given offsets.

Dim FileNum As Long
Dim TotalFile As String
FileNum = FreeFile
Open YourFileNameAndPath For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum

At this point, the TotalFile variable contains the entire file as a String.

Rick


.



Relevant Pages

  • Re: Array Reference
    ... Public TotalFile As String ... Dim FileNum As Integer ... Dim TotalFile As String ...
    (microsoft.public.vb.general.discussion)
  • Re: How to read text-file into VB?
    ... I added the listbox to see if I got the right things. ... Function ReadExcludeFile(sFileNameAndPath As String) ... Dim FileNum As Long ... Dim TotalFile() As Byte ...
    (microsoft.public.vb.general.discussion)
  • Re: How to read text-file into VB?
    ... Function ReadExcludeFile(sFileNameAndPath As String) ... Dim ChosenFile As String ... Dim FileNum As Long ... Dim TotalFile() As Byte ...
    (microsoft.public.vb.general.discussion)
  • Re: Excel in VB 6.0
    ... >> You can load the entire file into a String variable like this... ... >> Dim FileNum As Long ... >> Dim TotalFile As String ... >> Fields = Split, Delimiter) ...
    (microsoft.public.vb.general.discussion)
  • Re: Reading test file
    ... I'd read the whole file into a string variable, ... Dim FileNum As Long ... Dim TotalFile As String ... Thanks Rick, I'll have to give that a try. ...
    (microsoft.public.vb.general.discussion)