Making a program that can save, open and print

scottbogert

Member
Joined
Feb 23, 2006
Messages
8
Programming Experience
1-3
I've made a program, but now I need to make it save, open, and print. Any Suggestions?
 
use the PrintDocument for manual printing but if you're printing database info then you can use CrystalReports

for saveing and opening files simply use the save/open file dialogs for the user to specify file names and paths, then use the StreamReader and StreamWriter classes to actualy save and read data
 
How do I setup the streamreader and streamwritters? Do I not have to make a new file type? The print form part works great!
 
Last edited:
Dim SW As New StreamWriter(FilePath)
Dim SR As New StreamReader(FilePath)

SW.WriteLine(Contents)
Variabel = SR.ReadLine

they're pretty easy to use
 
Problems with sr and sw

I got a message that said
Error 3 Overload resolution failed because no accessible 'New' accepts this number of arguments. C:\Documents and Settings\sbogert\My Documents\Visual Studio 2005\Projects\GCDES\GCDES\Form1.vb 134 13 GCDES
for the SW. I also got this one for the SR.
Error 4 Overload resolution failed because no accessible 'New' accepts this number of arguments. C:\Documents and Settings\sbogert\My Documents\Visual Studio 2005\Projects\GCDES\GCDES\Form1.vb 139 13 GCDES
. Also, this comes up
Error 5 Name 'Variabel' is not declared. C:\Documents and Settings\sbogert\My Documents\Visual Studio 2005\Projects\GCDES\GCDES\Form1.vb 140 9 GCDES
. One last problem. How can I fix how my form prints? I was hoping it could be the size of the page, but it isn't. It's shorter, and cut part of the right side off. How would I fix this? Do I need to resize my form?
 
for the 1st two error messages it's because you've got the "134 12 GCDES" at the end, which isnt part of the filename

so change it to:
Dim SW As New StreamWriter("C:\Documents and Settings\sbogert\My Documents\Visual Studio 2005\Projects\GCDES\GCDES\Form1.vb")
and it'll work, respectively

for the last error message, it's because i used the word "variable" to show that a variable is used to hold the information that the streamreader reads in, the variable can be of whatever name you want, you just have to declare it before using it
 
Reply

The "134 12 GCDES" was the line of code in the error message. Sorry about the confusion! The problem with this method of streamwriting is that I'm using 40 something controls to have info in. How do I do it in this method?
 
sometimes coding like this can be tedious, but that's why we have the option of making sub's

i would make a sub that does all of the StreamWriter stuff so whereever you need to write the info to the file(s) simply call that sub

by doing it this way you really only code the stuff once, then when you need to make changes to how it saves the data and whatnot, just change it in the sub and that's it
 
Back
Top