Beginner's Question on saving arrays to a file.

B

Bill Maher

I have an array that I use to write to the file on the C:\
drive.

I want to print the file. How can I do it.

Here is my code for the write to the file:

I'm using "writeline". To allow for possibly deleted
items, i first check for emptry strings, and then I do
datMemory.writeline(eachItem). Here is my code for saving:

Dim datMemory As New StreamWriter("MemoryHelper.txt")
Dim intIndex As Integer
Dim intMaximum As Integer

intMaximum = lstDisplay.Items.Count

Do Until intIndex = intMaximum

If Not MemRecords(intIndex).strText = "" Then
datMemory.WriteLine(MemRecords(intIndex).strSubject)
datMemory.WriteLine(MemRecords(intIndex).datDate)
datMemory.WriteLine(MemRecords(intIndex).strText)
Else
intMaximum += 1
End If
intIndex += 1
Loop

datMemory.Close()
mblnIsDirty = False
 
M

Mike Caputo

Well, first I'd say you should use a "For Each" loop to make your life
easier (you can do this even with arrays since they now implement the
ICollection interface).

As for printing, just use a PrintDocument object.

--


Michael Caputo
Programmer/Database Administrator
Simon Economic Systems Ltd.
847-272-7691
(e-mail address removed)

I have an array that I use to write to the file on the C:\
drive.

I want to print the file. How can I do it.

Here is my code for the write to the file:

I'm using "writeline". To allow for possibly deleted
items, i first check for emptry strings, and then I do
datMemory.writeline(eachItem). Here is my code for saving:

Dim datMemory As New StreamWriter("MemoryHelper.txt")
Dim intIndex As Integer
Dim intMaximum As Integer

intMaximum = lstDisplay.Items.Count

Do Until intIndex = intMaximum

If Not MemRecords(intIndex).strText = "" Then
datMemory.WriteLine(MemRecords(intIndex).strSubject)
datMemory.WriteLine(MemRecords(intIndex).datDate)
datMemory.WriteLine(MemRecords(intIndex).strText)
Else
intMaximum += 1
End If
intIndex += 1
Loop

datMemory.Close()
mblnIsDirty = False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top