Solved

saving text and data arrays to a disk file

Posted on 1998-10-21
4
144 Views
Last Modified: 2010-04-30
ok what is the cleanest and quickest way to save the contents of an three dimensional variant array to disk (preferable as a binary file not ASCII)
0
Comment
Question by:spg01
4 Comments
 
LVL 1

Expert Comment

by:zivf
ID: 1440951
No clean way but to create a special function for it?
Don't you know the data type of the array items?
In MFC you have serialization, but it is internally managed, and to say gently, not the easiest thing in the world to design and program...
0
 
LVL 2

Expert Comment

by:gikam
ID: 1440952
declare the variabile say xxx as 3d array type
use PUT #1,xxx
0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 50 total points
ID: 1440953
Instead of an tridimentional array, make an array of a userdefined type.

This example uses the Put statement to write data to a file. Five records of the user-defined type Record are written to the file.

Type Record      ' Define user-defined type.
      ID As Integer
      Name As String * 20
End Type

Dim MyRecord As Record, RecordNumber      ' Declare variables.
' Open file for random access.

Open "TESTFILE" For Random As #1 Len = Len(MyRecord)

For RecordNumber = 1 To 5      ' Loop 5 times.
    MyRecord.ID = RecordNumber      ' Define ID.
    MyRecord.Name = "My Name" & RecordNumber   ' Create a string.
    Put #1, RecordNumber, MyRecord      ' Write record to file.
Next RecordNumber

Close #1      ' Close file.

if you want to encrip your data, use Xor operator

Hope this helps
Regards
0
 
LVL 1

Expert Comment

by:lawnranger
ID: 1440954
How about back to (Visual) Basics?
I respectfully submit the following...

Dim a(1 To 10, 1 To 10) As Integer
Dim b(1 To 10, 1 To 10) As Integer
Dim i As Integer, j As Integer
For i = 1 To 10
  For j = 1 To 10
    a(i, j) = i * j
  Next j
Next i
Open "C:\Test.bin" For Binary As #1
Put #1, , a
Close #1
Open "C:\Test.bin" For Binary As #2
Get #2, , b

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question