borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Flexgrid and ADODC)Next Topic (Data Report - Date Type field) New Topic New Poll Post Reply
AndreaVB Forum : Printing : printing in differents printers from VB
Poster Message
daserca
Level: Guest


icon printing in differents printers from VB

Hi everyone:
I need some help with a VB code.
I am doing some printings from VBasic, and work with an Epson LX-300 with good results for my purpose. But when I tried to use my program with an Epson LX-300+ it printed with different font and size, and all my work went to the garbage.
I tried with some ESC commands but did't work, please if anybody can help me to configure any Epson printer from VBasic and print my text with no changes in the font and size, I wil very grateful

My code is:
    Open "lpt1" For Output As #1
    Print #1, Chr$(27) & Chr$(107) & "1"    'antes 10
    'Print #1, Chr$(27) & "2"
    'Print #1, Chr$(27) & Chr$(69);
    Print #1, Tab(68); "BANCO SOLIDARIO S.A."
    Print #1, Tab(65); lblRUC.Caption & " " & txtRUC.Text; Spc(3); lblBanco.Caption & "   " & txtSucursal.Text & " " & txtCajero.Text & " " & txtSecuencial.Text; Spc(13); txtAleatorio.Text
    Print #1, Tab(84); lblCajero.Caption & " " & txtNomCajero.Text
    Print #1, Chr$(27) & "2"
    Close #1

    This is the text I want to preserve in any Epson Printer
    Printer.FontName = "Arial Black"
    Printer.FontSize = 10
    Printer.Print Tab(54); "BANCO SOLIDARIO S.A."
    Printer.FontName = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 8.5
    Printer.Print Tab(65); lblFormulario.Caption & txtFormulario.Text; Spc(3); lblOrden.Caption & " " & txtOrden.Text; Spc(4); mskFecha.Text & " " & mskHora.Text
    Printer.CurrentY = Printer.CurrentY + 3
    If txtpago.Text = 0 Then
        Printer.Print Tab(65); lblPagoBanco.Caption & " " & lblPago.Caption; Spc(7); txtpago.Text & " Otros:"
   Else
       VTLongitud = Len(txtpago.Text)
        Printer.Print Tab(65); "Pago en Banco:"; Spc(11 - VTLongitud); txtpago.Text & " " & lblPago.Caption; Spc(8 - VTLongitud); txtpago.Text & " Otros:"
    End If
    Printer.CurrentY = Printer.CurrentY + 3
    Printer.Print Tab(65); lblRUC.Caption & " " & txtRUC.Text; Spc(3); lblBanco.Caption & "   " & txtSucursal.Text & " " & txtCajero.Text & " " & txtSecuencial.Text; Spc(13); txtAleatorio.Text
    Printer.CurrentY = Printer.CurrentY + 3
    Printer.Print Tab(84); lblCajero.Caption & " " & txtNomCajero.Text
    Printer.EndDoc


13-05-2004 at 09:47 PM
| Quote Reply
lakki_lakki
Level: Guest

icon Re: printing in differents printers from VB

Hi, well they are many ways to do "printing", rememmber Epson printer has own defualt settings, check that first, before you do anything else.  

cheers
lakki

14-05-2004 at 06:56 AM
| Quote Reply
daserca
Level: Guest

icon Re: printing in differents printers from VB

Hi lakki_lakki
Thanks for your answer, about your suggestion I already did that. My main problem I want to configure the printers from the VB code, with out "touching" the printers. Maybe somebody knows the right order of the ESC commands in order to solve my problem

Thank you again

14-05-2004 at 12:40 PM
| Quote Reply
lakki_lakki
Level: Guest

icon Re: printing in differents printers from VB

well you can try using "dos mode" then the program find the printers..

you send first all you want to print to a file then print it like this..

Open "printer.bat" For Output As #3
    Print #3, "Type " & Chr(34) & "file.dat" & Chr(34) & " >> PRN"
    Close #3

'shell command to call the printer....
    Shell "printer.bat", vbHide

cheers.
lakki

14-05-2004 at 02:00 PM
| Quote Reply
daserca
Level: Guest

icon Re: printing in differents printers from VB


Thanks for your advise, but my text needs to be formated, I mean that some text has to be in Arial Black other just in Arial and the size of the text changes from one line to the others. And I think that if I write all my text into a fila I could not be able to make this changes

14-05-2004 at 02:47 PM
| Quote Reply
lakki_lakki
Level: Guest

icon Re: printing in differents printers from VB

Hi, there are many ways to do the type of printing you want..

you can do one more thing..make a fucntion to call the printing..then you can use so many fonts you want.. it will print without you need to choose the printer..try that, if not then i am here, printing is no problem..

try that..

lakki

14-05-2004 at 03:14 PM
| Quote Reply
daserca
Level: Guest

icon Re: printing in differents printers from VB

lakki_lakki:

Thank you for your help and time, I will try to explain better my problem (my English is not very good).

I did a program to print some text, and when I develop my program I worked with an Epson LX-300. I used the .FontName property and the .FontSize property, all the results were really good.
But when I used another printer (and Epson LX-300+) the printer changed everything, the fonts and the size of my text. I tried to configure the printer manually but I couldn't change the configuration. Now my boss asked me to configure the printer automatically, with VB code. I used some ESC commands but I didn't find the size and the font that I need.

I hope I explained myself clearly. Please if you have any suggestions, to configure the printers automatically, let me know

Thank you again

14-05-2004 at 09:08 PM
| Quote Reply
daserca
Level: Guest

icon Re: printing in differents printers from VB

HI again:

I'm sorry I think that I didn't understand your last message. please if you know how to make that funtion send me some example of the code.
I really appreciate your help
    

14-05-2004 at 09:16 PM
| Quote Reply
lakki_lakki
Level: Guest

icon Re: printing in differents printers from VB

will it looks like a problem in your "driver" i am sure about that, reinstall your drivers. Or you do can try this..


Private Sub Printline_1(S As String)

Printer.CurrentX = 50
Printer.Print S

End Sub

now you can call this metode/function to print..like

Private Sub cmdPrintIT_Click()

Printer.FontName = "Courier New"
Printer.FontSize = "11"
Printer.font = True
Printline_1 "It should print in Courier"
Printer.print
Printer.font = false

Printer.font = "Arial"
Printer.font = true

ect..

try this i hope it works.. if not then nothing wrong with the programming, but it must be wrong with the priner driver..for sure

cheers



15-05-2004 at 10:38 AM
| Quote Reply
daserca
Level: Guest

icon Re: printing in differents printers from VB

Hi again
You were right, my driver had problems, but I also include the next sequence of characters
Printer.Print Chr$(27) + Chr$(38) + Chr(108) + Chr$(49) + Chr$(79) before the printing

for some configuration in the printer. But unfortunately my printer prints the special characters (I don't want that). I tried with the printer.forecolor=7 (white), still the problem

I also tried
    Open "lpt1" For Output As #1
    Print #1, Chr$(27) + Chr$(38) + Chr(108) + Chr$(49) + Chr$(79)
    Close #1


Of course with this code my printer doesn't print the characters but it gives me other results that I don't want.

I wonder if you know how to not print the sequence
Printer.Print Chr$(27) + Chr$(38) + Chr(108) + Chr$(49) + Chr$(79)
with any printer property

Thank you again

17-05-2004 at 09:44 PM
| Quote Reply
lakki_lakki
Level: Guest

icon Re: printing in differents printers from VB

well, i never tried that you can try it by your self...i will try to find it  later..sorry i am a lit busy today..

lakki

19-05-2004 at 07:46 AM
| Quote Reply
daserca
Level: Guest

icon Re: printing in differents printers from VB

I decided not to use my sequence of characters.

Well I solved my problem, thank you for all your help. I really appreciated it.
Maybe if I have problems in the future I'll come to this forum, by the way is very cool and useful, and reached you.

Again thank you very much         

20-05-2004 at 04:31 PM
| Quote Reply
lakki_lakki
Level: Guest

icon Re: printing in differents printers from VB

Nice to know that you solved your problem, i am very happy for you.. good luck in the future

lakki

20-05-2004 at 07:32 PM
| Quote Reply
AndreaVB Forum : Printing : printing in differents printers from VB
Previous Topic (Flexgrid and ADODC)Next Topic (Data Report - Date Type field) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder