AllExperts > Qbasic, Quickbasic 
Search      
Qbasic, Quickbasic
Volunteer
Answers to thousands of questions
 Home · More Qbasic, Quickbasic Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex Barry
Expertise
I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience
Hobby programming since 2000

I no longer belong to any community programming groups, but do have knowledge of *basic dialects and C/C++

 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > QuickBasic 4.5

Qbasic, Quickbasic - QuickBasic 4.5


Expert: Alex Barry - 3/25/2009

Question
Hi Alex,I've made quite a lot of programs in QB,they still run as EXE prog.in XP & Vista but since USB printers no
longer seem to understand DOS I can't get a  print-out on
paper. Do you know of any routine that would work like
"PrtScrn" that I could call from anywhere in the prog.?
Thanks and greetings from Antwerp. L.

Answer
Hi, Laurent,

Yes, it is true, DOS has some trouble communicating with USB printers, but there is a handy trick you can use.  First, make sure anything you print on the screen also gets printed into a file.  Here is an easy way of doing that:

DECLARE SUB Print2( text AS STRING, fileHandle AS INTEGER )

DIM f AS INTEGER

f = FREEFILE

OPEN "tmp.txt" FOR RANDOM AS #f

' Instead of using: PRINT "text", now do Print2 "text", f
Print2 "This is a test", f

CLOSE #f
END

SUB Print2( text AS STRING, fileHandle AS INTEGER )
 PRINT text
 PRINT #fileHandle, text
END SUB

Now, after you have that, here is what I would do.  Note, this ONLY works for TEXT...if you are drawing graphics
So,  in the part of the code that looks like this:
CLOSE #f
END

Inbetween that, put this:
SHELL "notepad.exe /P tmp.txt"

This opens and prints it through windows' notepad program.  This is a bit of a cheap hack way of doing it, but it works, and it will use Windows' printer-usb drivers, so you won't have any problems.

I hope that helps,
-Alex

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.