By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,680 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,680 IT Pros & Developers. It's quick & easy.

Beginner's Question on saving arrays to a file.

P: n/a
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).strSubjec t)
datMemory.WriteLine(MemRecords(intIndex).datDate)
datMemory.WriteLine(MemRecords(intIndex).strText)
Else
intMaximum += 1
End If
intIndex += 1
Loop

datMemory.Close()
mblnIsDirty = False

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
mi************@radarwire.com

"Bill Maher" <wm****@naic.org> wrote in message
news:03****************************@phx.gbl...
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).strSubjec t)
datMemory.WriteLine(MemRecords(intIndex).datDate)
datMemory.WriteLine(MemRecords(intIndex).strText)
Else
intMaximum += 1
End If
intIndex += 1
Loop

datMemory.Close()
mblnIsDirty = False
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.