Solved

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

Posted on 2002-07-03
12
331 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
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
 

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 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

20 Experts available now in Live!

Get 1:1 Help Now