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 (Print method is not avaliable)Next Topic (flexgridline printing) New Topic New Poll Post Reply
AndreaVB Forum : Printing : Printing problem in VB on Dot Matrix Printer
Poster Message
gyanugyan
Level: Guest


icon Printing problem in VB on Dot Matrix Printer

Please tell me how can we print on Dot Matrix Printer using this code "Printer.Print", as i used it but i am not getting proper printout on Dot Matrix Printer while on Ink Jet Printer printout is proper. On Dot Matrix Printer it prints only 10-12 characters of each line, it does not print complete line. So please if any you can solve it, please let me know.

Thanks & Regards

Gyanendra Jain

18-06-2003 at 08:26 AM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Printing problem in VB on Dot Matrix Printer

A couple of questions please.

Is the dot matrix printer a serial or parallel printer?

Are you using the correct windows printer driver for the printer?

Does the test print work?

Can you go to dos and print a file (for example config.sys) to the printer, if so does that work?



[Edited by steve_w on 18-06-2003 at 09:48 AM GMT]

18-06-2003 at 09:17 AM
View Profile Send Email to User Show All Posts | Quote Reply
gyanugyan
Level: Guest

icon Re: Printing problem in VB on Dot Matrix Printer

It Is the  parallel printer

Ya using the correct windows printer driver for the printer

test print work

Ya, it print a file (for example config.sys) to the printer correctly.

But it not working in above case

18-06-2003 at 01:19 PM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Printing problem in VB on Dot Matrix Printer

  Don't really know.

I take it you're not changing fonts/colours.

Any chance of seeing the bit of code that does the printing please?

18-06-2003 at 01:43 PM
View Profile Send Email to User Show All Posts | Quote Reply
gyanugyan
Level: Guest

icon Re: Printing problem in VB on Dot Matrix Printer

Code is given below
This code is working well in case of Ink Jet Printer But in Dot Matrix Printer its not working, it just print first 10-12 characters of each line

***************************************************
Private Sub printCode()
    Printer.Height = 16840
    Printer.ScaleHeight = 15890

    Printer.Font = "Courier New"
    Printer.FontSize = 9
    Printer.FontBold = False
    Printer.TextWidth (80)
    Printer.FontBold = True
    Printer.Print Tab(4); "1.  NAME: " & txtName.Text
    Printer.FontBold = False
    Printer.Print Tab(4); "2.  FATHER'S NAME: " & txtFatherName.Text
    Printer.Print Tab(4); "3.  ADDRESS: " & printString(txtAddress.Text, 83)
    Printer.Print Tab(4); "    PIN: " & printString(txtPinCode.Text, 41) & "TELEPHONE: " & txtPhone.Text
    Printer.Print Tab(4); "4.  Permanent Account Number: " & printString(txtPAN.Text, 20) & "8.  Ward/Circle/Special Range: " & printString(txtWardCircle.Text, 19)
    
    Printer.Print Tab(4); "5.  Date of Birth: " & printString(DOB.Value, 31) & "9.  Sex: " & sex
      
    Printer.Print Tab(4); "6.  Individual/Hindu Undivided family/Firm/       " & "10. Income for the previous year"
    Printer.Print Tab(4); "    Association of Persons/Local Authority:       " & "    i.e., " & prevFrom.Value & " To " & prevTo.Value
    Printer.Print Tab(4); "    " & printString(CStr(personType), 45) & " 11. Assessment Year:" & txtAssessYear.Text
    
    Printer.Print Tab(4); "7.  Resident/Non-Resident/Not Oridinarily Resident" & "12. Return: " & returnType
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    Printer.Print Tab(4); "13. Details of *Bank Accounts"
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    Printer.Print Tab(4); "    Name of The Bank                 | Address of Branch                | Account No.               "
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    Printer.Print Tab(4); "    " & printString(txtBankName.Text, 32) & " | " & printString(txtBranchAddress.Text, 32) & " | " & printString(txtAcNo.Text, 25)
    'Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    'Printer.Print Tab(4); "      *Please Tick the Bank Account, where you would like the amount of refunt to be credited       "
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    Printer.Print Tab(4); "14. Detail of Credit Card            | Credit Card Number               | Issued by                 "
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    Printer.Print Tab(4); "    " & printString(txtCCDetail.Text, 32) & " | " & printString(txtCCNo.Text, 32) & " | " & printString(txtIssuedBy.Text, 25)
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    
    Printer.Print Tab(4); "15. INCOME FROM SALARY(Attached Form No. 16) " & printBlank(txtSalary.Text, 31) & "Rs.|" & printStringR(txtSalary.Text, 20)
    Printer.Print Tab(4); "16. INCOME FROM HOUSE PROPERTY               " & printBlank(txtHouse.Text, 31) & "Rs.|" & printStringR(txtHouse.Text, 20)
    Printer.Print Tab(4); "17. INCOME FROM BUSINESS OR PROFESSION       " & printBlank(txtBusiness.Text, 31) & "Rs.|" & printStringR(txtBusiness.Text, 20)
    Printer.Print Tab(4); "18. CAPITAL GAINS          15/9       15/12     15/3      31/3      TOTAL      |"
    Printer.Print Tab(4); "    (a)Short Term " & printBlank(txtCGShort.Text, 6) & "   " & printString(txtCGShort159.Text, 8) & "   " & printString(txtCGShort1512.Text, 8) & "  " & printString(txtCGShort153.Text, 8) & "  " & printString(txtCGShort313.Text, 8) & "  " & printString(txtCGShortTotal.Text, 8) & "Rs.|"
    Printer.Print Tab(4); "    (a)Long Term  " & printBlank(txtCGLong.Text, 6) & "   " & printString(txtCGLong159.Text, 8) & "   " & printString(txtCGLong1512.Text, 8) & "  " & printString(txtCGLong153.Text, 8) & "  " & printString(txtCGLong313.Text, 8) & "  " & printString(txtCGLongTotal.Text, 8) & "Rs.|" & printStringR(CSng(txtCGLongTotal.Text) + CSng(txtCGShortTotal.Text), 20)

    
    Printer.Print Tab(4); "19. INCOME FROM OTHER SOURCES                " & printBlank(txtOther.Text, 31) & "Rs.|" & printStringR(txtOther.Text, 20)
    Printer.Print Tab(4); "20. INCOME OF OTHER PERSON TO BE ADDED       " & printBlank(txtAdded.Text, 31) & "Rs.|" & printStringR(txtAdded.Text, 20)
    Printer.Print Tab(4); "21. GROSS TOTAL (15+16+17+18+19+20)          " & printBlank(txtGross.Text, 31) & "Rs.|" & printStringR(txtGross.Text, 20)
    Printer.Print Tab(4); "22. LESS: DEDUCTIONS UNDER CHAPTER VI-A:   SECTION           AMOUNT(Rs.)       |"
    Printer.Print Tab(4); "    (a)                                    " & printString(txtDedSectionA.Text, 13) & "     " & printString(txtDedAmountA.Text, 13) & "     |"
    Printer.Print Tab(4); "    (b)                                    " & printString(txtDedSectionB.Text, 13) & "     " & printString(txtDedAmountB.Text, 13) & "     |"
    Printer.Print Tab(4); "    (c)                                    " & printString(txtDedSectionC.Text, 13) & "     " & printString(txtDedAmountC.Text, 13) & "  Rs.|"; printStringR(CSng(txtDedAmountA.Text) + CSng(txtDedAmountB.Text) + CSng(txtDedAmountC.Text), 20)
    Printer.Print Tab(4); "23. TOTAL INCOME: (21-22)                    " & printBlank(txtTotal.Text, 31) & "Rs.|" & printStringR(txtTotal.Text, 20)
    Printer.Print Tab(4); "24. ADD: AGRICULTURAL INCOME (For rate purpose) " & printBlank(txtAgriculture.Text, 28) & "Rs.|"; printStringR(txtAgriculture.Text, 20)
    Printer.Print Tab(4); "25. INCOME CLAIMED TO BE EXEPTED FROM INCOME TAX " & printBlank(txtExempted.Text, 27) & "Rs.|" & printStringR(txtExempted.Text, 20)
    Printer.Print Tab(4); "26. TAX ON TOTAL INCOME                   INCOME            INCOME TAX         |"
    Printer.Print Tab(4); "    (a) At normal rates  " & printBlank(txtTaxNormalRate.Text, 17) & printString(txtNormalIncome.Text, 13) & "     " & printString(txtNormalTax.Text, 13) & "      |"
    Printer.Print Tab(4); "    (b) At special rates " & printBlank(txtTaxSpecialRate.Text, 17) & printString(txtSpecialIncome.Text, 13) & "     " & printString(txtSpecialTax.Text, 13) & "   Rs.|" & printStringR(CSng(txtNormalTax.Text) + CSng(txtSpecialTax.Text), 20)
    Printer.Print Tab(4); "27. LESS: REBATE                             " & printBlank(txtRebate.Text, 31) & "Rs.|" & printStringR(txtRebate.Text, 20)
    Printer.Print Tab(4); "28. TAX PAYABLE                              " & printBlank(txtTaxPayable.Text, 31) & "Rs.|" & printStringR(txtTaxPayable.Text, 20)
    Printer.Print Tab(4); "29. ADD: SURCHARGE                           " & printBlank(txtSurcharge.Text, 31) & "Rs.|" & printStringR(txtSurcharge.Text, 20)
    Printer.Print Tab(4); "30. TOTAL TAX PAYABLE (28+29)                " & printBlank(txtTTaxPayable.Text, 31) & "Rs.|" & printStringR(txtTTaxPayable.Text, 20)
    Printer.Print Tab(4); "31. LESS: RELIEF                             " & printBlank(txtRelief.Text, 31) & "Rs.|" & printStringR(txtRelief.Text, 31)
    Printer.Print Tab(4); "32. NET TAX PAYABLE                          " & printBlank(txtNTaxPayable.Text, 31) & "Rs.|" & printStringR(txtNTaxPayable.Text, 20)
    Printer.Print Tab(4); "33. LESS: TAX DEDUCTED AT SOURCE             " & printBlank(txtTaxDedSource.Text, 31) & "Rs.|" & printStringR(txtTaxDedSource.Text, 20)
    
    If CSng(txtAdvTax1.Text) > 0 Then
        dateStr = printString(advDate1.Value, 20)
    Else
        dateStr = printString("", 20)
    End If
    If CSng(txtAdvTax2.Text) > 0 Then
        dateStr = dateStr & printString(advDate2.Value, 20)
    Else
        dateStr = dateStr & printString("", 20)
    End If
    If CSng(txtAdvTax3.Text) > 0 Then
        dateStr = dateStr & printString(advDate3.Value, 20)
    Else
        dateStr = dateStr & printString("", 20)
    End If
    
    Printer.Print Tab(4); "34. LESS: ADVANCE TAX PAID                                                     |"
    'Printer.Print Tab(4); "         Date               Date               Date                            |"
    Printer.Print Tab(4); "       " & dateStr & "            |"
    'Printer.Print Tab(4); "         Amount             Amount             Amount                          |"
    Printer.Print Tab(4); "       " & printString(txtAdvTax1.Text, 20) & printString(txtAdvTax2.Text, 20) & printString(txtAdvTax3.Text, 17) & printString((CSng(txtAdvTax1.Text) + CSng(txtAdvTax2.Text) + CSng(txtAdvTax3.Text)), 12) & "Rs.|" & printStringR((CSng(txtAdvTax1.Text) + CSng(txtAdvTax2.Text) + CSng(txtAdvTax3.Text)), 20)
    Printer.Print Tab(4); "           (Under Section)    234A        234B        234C        TOTAL        |"
    Printer.Print Tab(4); "35. ADD: INTEREST PAYABLE   " & printString(txtInterestA.Text, 12) & printString(txtInterestB.Text, 12) & printString(txtInterestC.Text, 12) & printString((CSng(txtInterestA.Text) + CSng(txtInterestB.Text) + CSng(txtInterestC.Text)), 12) & "Rs.|" & printStringR((CSng(txtInterestA.Text) + CSng(txtInterestB.Text) + CSng(txtInterestC.Text)), 20)
    Printer.Print Tab(4); "36. LESS: SELF ASSESSMENT TAX PAID           " & printString("On Date " & SATPaidDate.Value, 31) & "Rs.|" & printStringR(txtSelfAssessment.Text, 20)
    Printer.FontBold = True
    If CSng(txtBalanceTax.Text) >= 0 Then
        Printer.Print Tab(4); "37. BALANCE TAX: PAYABLE/REFUNDABLE          " & printBlank(txtBalanceTax.Text, 31) & "Rs.|" & printStringR(txtBalanceTax.Text, 20)
    Else
        Printer.Print Tab(4); "37. BALANCE TAX: PAYABLE/REFUNDABLE          " & printBlank(txtBalanceTax.Text, 31) & "Rs.|" & printStringR("(" & txtBalanceTax.Text & ")", 20)
    End If
    Printer.FontBold = False
    Printer.Print Tab(4); "----------------------------------------------------------------------------------------------------"
    Printer.FontUnderline = True
    Printer.Print Tab(4); "DOCUMENT ATTACHED WITH THE RETURN"
    Printer.FontUnderline = False
    
    
    Printer.Print Tab(4); "                                              VERIFICATION                                          "
    Printer.FontBold = True
    Printer.Print Tab(4); "I " & printString(UCase(txtName.Text), 40) & " son/daughter of " & printString(UCase(txtFatherName.Text), 42)
    Printer.FontBold = False
    Printer.Print Tab(4); "solemnly decalare that to the best of my knowledge and belief,  the information given in this return"
    Printer.Print Tab(4); "and annexures and statements accompnying it are correct, complete and truly stated and in accordance"
    Printer.Print Tab(4); "with the  provisions of Income Tax Act, 1961, in respect  of income chargeable to income tax for the"
    Printer.Print Tab(4); "previous year relevant to the assessment year " & txtAssessYear.Text & "."
    'Printer.Print Tab(4); ""
    Printer.Print Tab(4); "Receipt No.______________ Date __________"
    Printer.Print Tab(4); "                Seal                                              Signature "
    Printer.Print Tab(4); "                                                                  Date : "
    Printer.Print Tab(4); "    Signature of the receiving official                           Place:"
    Printer.EndDoc    
End Sub

Function printString(str As String, n As Integer) As String
    Dim i As Integer
    i = Len(str)
    If i >= n Then
        printString = Left(str, n)
    ElseIf i < n Then
        printString = str & Space(n - i)
    End If
End Function

Function printStringR(str As String, n As Integer) As String
    Dim i As Integer
    i = Len(str)
    If i >= n Then
        printStringR = Left(str, n)
    ElseIf i < n Then
        printStringR = Space(n - i) & str
    End If
End Function

**************************************************

18-06-2003 at 04:21 PM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Printing problem in VB on Dot Matrix Printer

How about printing just a large string

eg Printer.print "01234567890123456789012345678901234567890123456789012345678901234567890123456789"

If that works then it maybe something to do with the tab settings or the text width.

Another thought perhaps try increasing the printer.width value

18-06-2003 at 10:14 PM
View Profile Send Email to User Show All Posts | Quote Reply
gyanugyan
Level: Guest

icon Re: Printing problem in VB on Dot Matrix Printer

It is printing large string, when we have to print 2-3 lines it prints well, but when we have to go for a complete page or say 10-15 lines then it prints first 10-12 characters of each line. All this is happening in case of Dot Matrix Printer.

While in the case of Ink Jet Printer it is printing properly, if width problem or something like that then how it is printing on Ink Jet Printer and why it is not printing on Dot Matrix Printer??

19-06-2003 at 04:49 AM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Printing problem in VB on Dot Matrix Printer

When printing your form, does it start off printing 2 or 3 lines and then go to 10 or 12 characters, or does it start by printing only 10 or 12 chars. Also can you print the bigstring say for 40 lines. I am wondering with the text you are sending it if you somehow sending a sequence of characters that are part of the printers command set.

Also how how is the dot matrix printer.

19-06-2003 at 07:55 AM
View Profile Send Email to User Show All Posts | Quote Reply
nirmal
Level: Guest

icon Re: Printing problem in VB on Dot Matrix Printer

i think your problem is actually related to font.

Try to take printout with other fonts, such as 'Times New Roman'.

If your printer driver support 'Draft 12cpi' Font, try to print with this font.

15-10-2003 at 09:27 AM
| Quote Reply
Gorabnuoh
Level: Guest

icon Re: Printing problem in VB on Dot Matrix Printer

Hi why do you tray to set the paper size...

Printer.PaperSize = 9 <-- for A4
and this for the rest of sizes:-

Constant                   Value      Description
vbPRPSLetter               1          Letter, 8 1/2 x 11 in.  
vbPRPSLetterSmall       2          Letter Small, 8 1/2 x 11 in.  
vbPRPSTabloid             3          Tabloid, 11 x 17 in.  
vbPRPSLedger              4          Ledger, 17 x 11 in.  
vbPRPSLegal                5          Legal, 8 1/2 x 14 in.  
vbPRPSStatement         6          Statement, 5 1/2 x 8 1/2 in.  
vbPRPSExecutive          7          Executive, 7 1/2 x 10 1/2 in.  
vbPRPSA3                    8          A3, 297 x 420 mm  
vbPRPSA4                    9          A4, 210 x 297 mm  
vbPRPSA4Small            10        A4 Small, 210 x 297 mm  
vbPRPSA5                    11        A5, 148 x 210 mm  
vbPRPSB4                    12        B4, 250 x 354 mm  
vbPRPSB5                    13        B5, 182 x 257 mm  
vbPRPSFolio                 14        Folio, 8 1/2 x 13 in.  
vbPRPSQuarto              15       Quarto, 215 x 275 mm  
vbPRPS10x14               16       10 x 14 in.  
vbPRPS11x17               17       11 x 17 in.  
vbPRPSNote                 18       Note, 8 1/2 x 11 in.  
vbPRPSEnv9                19       Envelope #9, 3 7/8 x 8 7/8 in.  
vbPRPSEnv10 20 Envelope #10, 4 1/8 x 9 1/2 in.  
vbPRPSEnv11 21 Envelope #11, 4 1/2 x 10 3/8 in.  
vbPRPSEnv12 22 Envelope #12, 4 1/2 x 11 in.  
vbPRPSEnv14 23 Envelope #14, 5 x 11 1/2 in.  
vbPRPSCSheet 24 C size sheet  
vbPRPSDSheet 25 D size sheet  
vbPRPSESheet 26 E size sheet  
vbPRPSEnvDL 27 Envelope DL, 110 x 220 mm  
vbPRPSEnvC3 29 Envelope C3, 324 x 458 mm  
vbPRPSEnvC4 30 Envelope C4, 229 x 324 mm  
vbPRPSEnvC5 28 Envelope C5, 162 x 229 mm  
vbPRPSEnvC6 31 Envelope C6, 114 x 162 mm  
vbPRPSEnvC65 32 Envelope C65, 114 x 229 mm  
vbPRPSEnvB4 33 Envelope B4, 250 x 353 mm  
vbPRPSEnvB5 34 Envelope B5, 176 x 250 mm  
vbPRPSEnvB6 35 Envelope B6, 176 x 125 mm  
vbPRPSEnvItaly 36 Envelope, 110 x 230 mm  
vbPRPSEnvMonarch 37 Envelope Monarch, 3 7/8 x 7 1/2 in.  
vbPRPSEnvPersonal 38 Envelope, 3 5/8 x 6 1/2 in.  
vbPRPSFanfoldUS 39 U.S. Standard Fanfold, 14 7/8 x 11 in.  
vbPRPSFanfoldStdGerman 40 German Standard Fanfold, 8 1/2 x 12 in.  
vbPRPSFanfoldLglGerman 41 German Legal Fanfold, 8 1/2 x 13 in.  
vbPRPSUser 256 User-defined

09-01-2004 at 03:11 PM
| Quote Reply
pc888
Level: Graduate

Registered: 02-01-2004
Posts: 12
icon Re: Printing problem in VB on Dot Matrix Printer

If your printer is connected via a serial port, could you try connecting the through the parallel port and see if it gives the same results?

09-01-2004 at 08:30 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : Printing problem in VB on Dot Matrix Printer
Previous Topic (Print method is not avaliable)Next Topic (flexgridline printing) 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