Solved

About printing

Posted on 1998-11-10
6
127 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

22 Experts available now in Live!

Get 1:1 Help Now