Solved

saving text and data arrays to a disk file

Posted on 1998-10-21
4
140 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now