Solved

:-:- Print in DOS-TEXT Mode :-:-

Posted on 2002-07-03
12
335 Views
Last Modified: 2012-08-13
Dear Experts,

How can I print the text of a
RichTextBox in DOS-TEXT mode (not a graphical mode)
through a Dot-Matrix Printer
without given any printer settings.

srins
0
Comment
Question by:eesrinivaassan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 3

Expert Comment

by:schworak
ID: 7129117
You only want the TEXT of a RichTextBox?


TXT = RichTextBox1.Text
printer.print txt





If you wanted the rich text version you would use something like this. But printing rich text is a different story.

RTXT = RichTextBox1.TextRTF
0
 

Expert Comment

by:serco102497
ID: 7129118
' Ptext as text box  
  Printer.Print Chr(13) & Chr(13) & Chr(13)
  Printer.FontBold = False
  Printer.FontSize = 10
  Printer.Print Space(5) & Ptext
  Printer.EndDoc  ' Print done.
' I try this, it can print in any default printer
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7129677
serco, you have been here for 5 years, never asked nor answered a single question yet you have the 100% guaranteed answer that doesn't even refer to the actual control in use? Impressive. Please refer to the guidelines on comments vs answers at the bottom of this page. If you continue to post answers your account will be referred to customer services for possible penalty.

eesrinivaassan:

Indeed serco got it almost exactly right, though without discussing the RTB control it is not quite there.

The Rich TextBox Control has two properties, the .TextRTF and the .Text property, the former includes all of the RTF control characters and the formatting codes for the display of the text in the RTB. The latter is purely the plain text without any control codes. If you use this property you can output it to any printer either using the printer object or using any direct methods (api or other) to open and print to a printer.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:eesrinivaassan
ID: 7129707
Please kindly understand
I am not asking to just print the contents.
I want to print the RichTextBox Contents
through Dot-Matrix printer in
MS-DOS TEXT MODE.
(The Printed letter quality should be
just like the printing taken through
the following DOS command
c:\>dir >prn )

Now What I am doing is to accomplish the above,
I am first saving the contents of RichTexBox in
a file.  Then I am sending the contents of the
above file to printer through a batch file
contains the following line
copy <filename.txt> /b lpt1
I am running the batch file through SHELL command.

It works fine.

I want to know, is there any better Idea than the
above?
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 75 total points
ID: 7129715
Why not try this:

Open "LPT1" For Output As #1
Print #1,RichTextBox1.Text
Close #1
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 7129971
Q175083 - HOWTO: Print Line-by-Line to a Printer
http://support.microsoft.com/support/kb/articles/Q175/0/83.ASP 
0
 
LVL 3

Expert Comment

by:schworak
ID: 7130117
Question, why are you side stepping the windows driver?

If you simply want to dump text then the answer given by TimCottee should work fine. On the other hand. If you try to send special printer commands you will need to fully understand the printer you are sending to and be aware that changing printers could break your program.

It is posible to set up any printer to be a DOS printer which may be helpful.  I am just trying to fully understand why you are trying to print in the way you are instead of using the windows drivers.
0
 
LVL 3

Expert Comment

by:shankarkrupa
ID: 7132279
I think it is for speed.....correct, eesrineevaasan?
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7132534
The above TimCottee answer should do it, but I think the LPT1 needs a colon (:) after it.

Another way to do it, which actually used DOS is this:

Private Sub PrintRTB()
  const cTempFile as string = "C:\Temp\RTBText.txt"

  open cTempFile for output as #1
  print #1, RichTextbox1.Text
  Close #1
  Shell ("Command /c Copy " & cTempFile & " LPT1:")
  kill cTempFile
end sub
0
 
LVL 1

Expert Comment

by:riaz9
ID: 7134710
I too had put up a similar question sometime back. I was given 2 suggestions which unfortunately i could not completely try out (because i also wanted to change the size of font to big, bold . . .).

One was what TimCottee said

Open "LPT1" For Output As #1
Print #1,RichTextBox1.Text
Close #1

The other one is using the Escape API function
But i am not sure whether they will work for Windows NT also.

To
schworak:

The reason (most probably) why eesreenivaassan wants to directly print to the dot matrix printer via dos mode is that most of the automated work in India is in foxpro and printing via foxpro is fast. Windows printing is slow and end users who are moving to a visual interface like vb want the same speed and economy while printing.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7990578
Hi eesrinivaassan,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

eesrinivaassan, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 8050687
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 connector to mongodb 2 160
Error when passing an argument to a vb6 that contains  '/' 7 48
VB6 - Convert HH:MM into Decimal 8 75
Automatic Email Reminder 4 92
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 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