rnr 0 Newbie Poster

I have been struggling with this problem for a couple of days - and am now getting desperate. I am trying to extract data from a large binary file, about 64 mb. It is sequential binary records of two byte words. The values range from +32k to -32k, The variable is called NewDataU. After researching options it seems dimensioning it as
Dim NewDataU as Short would be the best approach. VB5 will not accept this! I have tried NewDataU% and now defaulted to NewDataU as integer; neither give the correct result.

This may be the problem, but I am not sure that I am using the correct syntact for extracting the data from the file. The code used is given below. This is an old program I have to rebuild, and have just finished many punishing rounds of fighting with active X controls. I would really appreciate help, I need sleep - too many 25 hour days.

Hope somebody can suggest solutions.

Thanks

RNR

Private Sub ExternalFileRead_click()
 Dim TransducerNumber As Integer
    Dim SensorData(8, 2048), ByteCountCount
    Dim NewData As Integer, Count As Integer
    Dim FileNameBin As String
    Dim FileRead As Integer, ByteCount As Integer, NumSensors As Integer



    ByteCount = 1
    NumSensors = 8
    RecLen = 16
    GlobalFileNameBin = "c:\Cylinder test files\Test Data\NGTestData"
    'Data Filename
'set parameters to correctly read the file.
'GlobalFileType = UEI
'_________________________________________________________________________________________________

'Start to loop through the data from each sensor.
    ' A data point for each transducer is read, repeated until the framesize is reached.

    FileRead = FreeFile
      Open GlobalFileNameBin For Binary Access Read As #FileRead Len = RecLen
    'Loop through the frame of data. Use an outer loop to read sequence of data frames (not shown)
    '
    'Don't forget to change word size to read two byte integer.
    'data is in two bytes (16 bit words){-32k to +32k)
    '(note: vb will not recognize "Dim NewDataU As Short to cover two bytes)

    'A Frame of data is 2048 bytes long, the data from transducers are read
    'sequentially 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8  ..... until 1024 data points are read
    '
    'Openfile to access data
    FileRead = FreeFile
    Open GlobalFileNameBin For Binary As #FileRead Len = 16
    Count = 1
    For ByteCount = 1 To 16000
    'Each transducer will have about 2000 datapoints
    For TransducerNumber = 1 To 8

          Input #FileRead, ByteCount, NewDataU
          SensorData(TransducerNumber, Count) = NewDataU
                'MsgBox "Transducer = " & TransducerNumber & NL & "New data point = " & NewDataU & NL & "ByteCount =  " & ByteCount & NL & "CountFrames = " & CountFrames
          SensorData(TransducerNumber, Count) = (SensorData(TransducerNumber, DataCount) - 2048) * 5 / 2048
          ByteCount = ByteCount + 2

     Next TransducerNumber
      Count = Count + 1
    Next ByteCount

     End



End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.