Error reading/writing to large .dat file
I have this large Excel table with 10 000 rows and 300 columns. I have this VB6 program that needs some of the data to preform some calcultations. But I dont whant a user to get access to the raw data.
My solution was to create a large .dat file to go with the program. Since the user dont know what is included in the .dat file it is hard to access the raw data. When my program access the data it only pick 100 records given some inital row and col. The problem is that my code cant handle this. It just gives me a compile error: "static data cant exceed 64 kb" when I try to write this .dat file. Does anyone know how to do this in another way or can I change my code in some way?
Code:
Public Type tStart
start(10000, 300) As Single
End Type
'Write to file:
#If writeFile Then
Static PStart As tStart
Open OutputFolder & FileStart For Random As #1 Len = Len(PStart)
For r = 0 To 300
For t = 1 To 10000
PStart.start(t,r) = LargeArray(t,r)
Next t
Next r
Put #1, , PStart
Close #1
#End If
'Read file
Static PStart As tStart, result() As Variant
ReDim result(0, 100)
Open OutputFolder & FileStart For Random As #1 Len = Len(PStart)
r=1
Get #1, , PStart
Close #1
For t = tStart To tStart +100
result(t-tStart+1,0) = PStart.start(t,r)
Next t
Re: Error reading/writing to large .dat file
What language is this ? It dosen't look like legacy VB which is where you've posted the question.
Re: Error reading/writing to large .dat file
Re: Error reading/writing to large .dat file
Using the Static decorator on a VB6 procedure causes all data declared within it to be Static. You can also decorate individual data declarations, which seems to be used here. The #If...#Else...#End If stuff is compile time conditionals for conditional compilation.
Static data always comes at a price, and you normally don't want to declare large Static items because the price can be high. They are also limited in size.
Move your big items to the General part of the module, i.e. ahead of all of your procedure (Sub and Function) declarations. Remove the Static keyword and use Dim or Private.
Re: Error reading/writing to large .dat file
I still cant get this to work. I define my type statement before the procedure. Even if I change from static to dim it says that it is too large.
I get the error: "Compact and static data may not exceed 64 kb"...
Re: Error reading/writing to large .dat file
Don't use a structure (type) .... make your tStart a class instead... change
Static PStart As tStart
to
Dim PStart As tStart
Set PStart = New tStart
I think that will overcome your size limitations.
-tg