Solved

About printing

Posted on 1998-11-10
6
129 Views
Last Modified: 2010-04-30
Hi

Note: Here are two questions, you are wellcome to answer any one or both. Depends on how difficult the questions are (I don't know at the moment), the points will be increased :-)

1. Without using Crystal Report or other application, how to write Print-Preview for simple text (may includes different size fonts) and small bmp?

2. Before exit a VB application, I would like to create a PostScript file and put some stuff into the file. Can you tell me how to send the file to the printer by VB code?
0
Comment
Question by:username1
  • 3
  • 3
6 Comments
 
LVL 3

Accepted Solution

by:
vikiing earned 80 total points
ID: 1444115
Answer for 2):

Open  "post-script.file" for binary as #1
Siz&=Lof(1)
Do
   Portion& = Siz& : If Portion& > 1024 then Portion&=1024
   If Portion& < 1 then Exit do
   Get$ #1,Portion&,Buffer$
   Printer.Print  Buffer$;
   Siz&=Siz&-Portion&
loop
Printer.Enddoc
Close #1

0
 

Author Comment

by:username1
ID: 1444116
Hi vikiing

Thank you for answer question 2.

Can you tell me:
1) Why we need 1024, not whole file in one go?
2) I remember we can send a PostScript file to the printer by
      c:\copy thefile.ps lpt1
   Is this possible doing that from VB?

Cheers.
0
 

Author Comment

by:username1
ID: 1444117
Adjusted points to 80
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 3

Expert Comment

by:vikiing
ID: 1444118
I see I didn't check the "e-mail notification".

You can read/write the file in a single chunk, provided file size be less than 64 Kb (the maximum length any string variable can have). But you must not forget that string space (the total area reserved for string handling) has its own restrictions also; your program will surely use another string variables, so you must be conservative about their use.

¿Why 1024 and not 1000?; simply 'cause 1024 is a multiple of 512, the size of a single disk sector. Using that size you can optimize a bit the time required to read data, by reading whole sectors instead fractions of it.


0
 

Author Comment

by:username1
ID: 1444119
To Vikiing:

Thank you.

I have found some mistakes you did :-)

> Portion& = Siz& : If Portion& > 1024 then Portion&=1024
>      If Portion& < 1 then Exit do
>      Get$ #1,Portion&,Buffer$

The second parameter (Portion&, in the above code) of Get$ is the position where getting starts. It shoul not be the size.....

Hope you can read my comment.
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1444120
Unfortunately, I suposed GET$ worked the same way as in Turbo Basic, where the second parameter specifies the amount of bytes to be read.

Sorry for the mistake... :(
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

776 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