Solved

Print Formatting help

Posted on 1999-01-14
5
137 Views
Last Modified: 2010-05-03
I have several text files, I need to print these and include a blank line between each printed line (as in double spaced)
I am a beginner to VB so please make it as simple and detailed as possible. If it isnt too much trouble I would apreciate it if someone would write me a procedure that will do this, where I can just put in the name of the file to be printed.
0
Comment
Question by:TrevorCharles
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:jjbyers
Comment Utility
Is this homework?
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 100 total points
Comment Utility

Dim intFile1 As Integer
Dim intFile2 As Integer
Dim strLineRead As String

intFile1 = FreeFile

Open "<your input file>" For Input As #intFile1

intFile2 = FreeFile
Open "<your output file>" For Output As #intFile2

Do While Not EOF(intFile1)
    Line Input #intFile1, strLineRead
    'Print strlineread but with double spacing
    Print #intFile2, strLineRead
    Print #intFile2, ""
Loop

Close #intFile1
Close #intFile2

0
 

Author Comment

by:TrevorCharles
Comment Utility
Thanks very much for answering my question, I apreciate it. Since I posted my origional message I realized that I would need additional features in the printing part of my program.

I use a file listbox that shows the various catalog files, the user clicks any one and its contents are displayed in a textbox called Text1 and the contents of this textbox are what need to be printed double spaced.

The file content when printed will fill more than one page and I dont know how to make the printing continue until the entire contents are printed, right now I have been using

 Printer.Print

and sending it the content of the textbox, this will not print the entire files content, it stops after the first page is printed. I've been typing the file in double spaced and printing it but this seems like a kludge to me.

If it would be possible I would like to have the procedure that Caraf_g sent me modified to work with my textbox text1, I think I can then figure out on my own how to modify it for use in other ways.

One more thing, I'm putting my printing code in the mnuPrint part of my main forms menu because it seems simplest that way, if you send me code I would apreciate it if you would write it so I can continue to use it in mnuPrint, I am not experienced enough with functions yet to be able to use one and pass it the filename to be printed.

Thanks very much for you help so far.

Trev
0
 
LVL 10

Expert Comment

by:caraf_g
Comment Utility
Instead of using a text box you could use a list box to display the contents of the file.

I assume you are using something like
Line Input #intFile1, strLineRead
to read each line from the file, so you can then use the List Box's AddItem method to add it to the list box.

Private Sub FillListBox(strFile As String)

Dim intFile1 As Integer
Dim strLineRead As String

intFile1 = FreeFile

Open strFile For Input As #intFile1

Do While Not EOF(intFile1)
    Line Input #intFile1, strLineRead
    'Print strlineread into list box with double spacing
    List1.AddItem strLineRead
    List1.AddItem ""
Loop

Close #intFile1

End Sub

'To Print, then:
For intCounter = 0 To List1.Count - 1
    Printer.Print List1.List(intCounter)
Next
0
 

Author Comment

by:TrevorCharles
Comment Utility
Once again I thank you very much for your assistance, I am very close to having what I want now.

The latest code you sent me will work quite well for the printing out of the order form, once this is printed we can use it to go around to the parts bins in the assembly room and write on it the quantity of the various parts to be ordered.

Right now a typical line of this printed form would read:

90633A009             1/4 x 20 x 1 3/4 Panhead Machine Screw

would there be a way to add a certain number of underscores after the part number as in:

90633A009____

If this could be done then it would be easier for the person making up the order to write the quantity needed on top of the underscores.

Earlier I forgot to mention that only when the ordering form is actually printed that it should be doublespaced, when it is just displayed in the listbox or textbox it should appear single spaced.

Trev
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now