Solved

About printing

Posted on 1998-11-10
6
130 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

820 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