[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2002-07-03
12
Medium Priority
?
340 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 300 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses

650 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