printing a text file in VB6

By vrinda ·
I have a text file created from within VB. I need to print it. I have been using DOS command till now "shell(type filename > prn)" but that was to printer connected at LPT. Now it is laser printer connected at USB or COMM port.
I am a beginner....



This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Printing from dos

by p.j.hutchison In reply to printing a text file in V ...

To print from dos to a non-LPT printer, you need to:
1. Share the printer using the Print and Faxes control panel
2. Open a command prompt
3. Type NET USE LPT1 \\computername\printershare
or some other LPT port.

4. Now print as normal e.g. TYPE >LPT1: myfile

5. Alternatively you could create a RichTextBox in VB and use one of its methods to print the text in the RTB.

Collapse -

Printing from dos

by vrinda In reply to Printing from dos

But i guess i cud not explain properly...

I need to print from within VB.
Can u give some command or something to start with? How to print text from RTB?


Collapse -

Answer of u r question ..

by zionsoft In reply to Printing from dos

pls use a richtext box and use following code


Happyy.. coding....!

By : Lenin Paily - Zionsoft

Collapse -

The Printer object is your friend

by Mirko.Klotz In reply to printing a text file in V ...

In VB6 there's a global printer object, called "Printer". You can write (using "Print") and paint (using numerous methods like "Line" or "Circle") on it very similar to the PictureBox object. The method "EndDoc" sends your stuff to the current printer.
There's also a collection named "Printers" containing all installed printers. You can use it to select where you want to print.


Collapse -

Printer object

by rob In reply to printing a text file in V ...

As someone else said, use the printer object in VB.
In simple terms:

printer.print MyTextBox.Text


There are a lot of other properties and methods you can play with.

Collapse -

Different Fonts

by vrinda In reply to Printer object

Thanx for the suggestion. But I need to change font size in between... some normal font size, some condensed font.... How do I do this from inside VB?


Collapse -


by p.j.hutchison In reply to Different Fonts

If you use a RichTextBox you can specify fonts and so on.

Alternatively, you can send the printer commands for your printer. ESC/P commands for Epson, PCL commands for HP Printer etc.

Collapse -

reliable printing method

by aikimark In reply to printing a text file in V ...

Shell "notepad.exe /P ""C:\TR\How To Print File From VB.txt""", vbNormalFocus

Back to Peripheral Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums