vb reporting for dot matrix

  • 13 years ago

    I have developed vb program (VB- 6.0) with data report. Now I want to get this to be printed with dot-matrix printer.But as all we know these data reports are graphical text, printing is very slow on dot matrix printer .What can I do to get faster printing of the reports with dot matrix printer ? Can anybody help me with the sample code?

  • 13 years ago

    A lot depends upon what your report was developed in: if its a third party tool, you may have little control over fonts or the actual rows of data to be output.

     

    here is a list of things you might investigate:

    Set the print quality to 'draft'

    Try using fonts that are built in to the printer - some printer drivers treat this as 'pass through' and just send the letters rather than a bitmap. (Example: Courier, Arial)

    If you have control of the actual text, you might try opening LPT1: as an output device, and using Print # to send actual letters straight to the printer.

     

  • 13 years ago

     

    Thanks for your reply & valuable time spared for me. 

    My reports are in vb 6.0 (data report).when I tried above options I got little bit improved speed but not expected speed.My exisiting printing  with dos base program is giving double of this speed ( I think it is printin in both stroke , fore stroke & back stroke). But with vb it is printing in fore stroke while back stroke is empty.My friends suggested me that these report should be in character mode.Do you have any idea about this.

     Thanks again,

    Nitin

  • 13 years ago
    Character mode may be possible if you use the printer fonts through the normal printer driver.
    perhaps there is an option there for unidirectional printing. (This was a way of trying to ensure that things lined up nicely - some old DM printers printed so fast left and right that the letters were skewed back and forwards according to which way the head was flying at the time)
     
    Otherwise, the only sure way to get the speed to DOS levels is to send the data straight to the LPT1: port
    (assuming this is a Dm printer plugged into your own PC with a parallel cable)
     
    If so, you can send control characters to the printer to do things exactly as you want.

    Most DM printers are Epson or IBM compatible, and follow a simple set of controls.
    For instance, sending CHR(27) , chr(17) to the printer says 'Print in 17 cpi'
    CHR(27), "K"  says "here comes some graphics data"
     
    Step one is to see if you can open a port to LPT1:, in the same way as you would open a disc based file for output.
    If so, second step is to
    Print# filenumber, "hello"
    close# filenumber
     
    and see if it prints.
     
    If so, then investigate the control set available for the specific printer by searching online and sending a printer setup string before you begin to print.
     
    You will find a list for Epsons at:
     
    where (for instance) you can see 'cancel unidirectional print' is chr(27),chr( 85), chr( 48 )
     
  • 13 years ago
    hi you can do the trick by byepassing the datareport. create your report in a text file instead. for example dim fso as filesystemobject dim ts as textstream set ts = fso.opentextfile("filePath") ts.write "...............Report Heading ......................" ts.wirte "------------------------------------------" ts.write "name | Class | Marks " ts.write "------------------------------------------" ts.write "Tom | BCA | 90 " ts.write "------------------------------------------" ts.close for windows xp use following command shell "CMD /C TYPE " & FilePath & " > PRN", vbNormalFocus for windows 98/Me use COMMAND in place of CMD regards manpreet singh dhillon hoshiarpur
  • 13 years ago

    Thank you very much for your reply & your valuable time spared for me. 

    code for command1_click() 

    Dim fso As FileSystemObject

    Dim ts As Textstream

    Set ts = fso.opentextfile("c:\New Folder")

    ts.write "...............Report Heading ......................"

    ts.wirte "------------------------------------------"

    ts.write "name | Class | Marks "

    ts.write "------------------------------------------"

    ts.write "Tom | BCA | 90 "

    ts.write "------------------------------------------"

    ts.Close 

    Shell "CMD /C TYPE " & "c:\New Folder & " > PRN", vbNormalFocus

    • If I Use this code, compile error is coming as "User-defined type not defined" for filesystemobject & textsream.
    • Is it neccessory to add any components in my components library for filesystem object like ADO?
    • because error is for filesystemobject & textsream

    Please advise

  • 13 years ago
    hi open project menu, select Refrences and Add reference to 'Microsoft Scripting Runtime' also append & vbCrlf at the end of each line you write with ts.Write vbcrlf adds newLine i.e. moves the cursor to the start of next line. if you dont add vbCrlf all the text will be written as single line. revised code must look like following ts.write "...............Report Heading ......................" & vbcrlf ts.wirte "------------------------------------------" & vbcrlf ts.write "name | Class | Marks " & vbcrlf ts.write "------------------------------------------" & vbcrlf ts.write "Tom | BCA | 90 " & vbcrlf ts.write "------------------------------------------" & vbcrlf regards manpreet singh dhillon
  • 13 years ago

    Thanks again,

    • Ok, This is now working upto file writing,Now how to pass this file to printer &
    • Shell "cmd /C  TYPE " & "c:\new folder" & " > PRN", vbNormalFocus
    • whtat this command actually do?
    • Also I have aother problem, i have Dot Matrix printer EPSON FX 1170, I want printing on this printer,when we print from ms dos program it is printing in both way i.e when printer head is moving from left to right & right to left.But when we pass text file to printer it is printing only when printer head is moving from left to right.is there any way to enable printing both way like dos program?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debuggers don't remove bugs. They only show them in slow motion.”