Beginner's Question on saving arrays to a file.

  • Thread starter Thread starter Bill Maher
  • Start date Start date
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
 
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
 
Back
Top