?
Solved

saving text and data arrays to a disk file

Posted on 1998-10-21
4
Medium Priority
?
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

719 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