Results 1 to 5 of 5

Thread: Garbled printing from compiled app

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Garbled printing from compiled app

    I have a VB6 app I wrote for a friend who now runs Windows 7 home premium 64 bit. The app runs correctly but the printing, using the printer object comes out garbled. A 10 line single page results in about 30 pages with a few skewed lines of text and then control type characters. Other programs print correctly. The app prints fine from the IDE but not after it's compiled.
    Any suggestions?

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Re: Garbled printing from compiled app

    Code extract is below. This will print fine to XPS, PDF or Dell laser while in the IDE. Once compiled t completes the print command but the output is completely garbled.


    Printer.Font.Name = "Arial"
    Printer.Font.Bold = True
    Printer.Font.Size = 12
    Printer.Scale (0, 3300)-(2550, 0)
    ' print column headers
    Printer.CurrentX = 200
    Printer.CurrentY = 200
    Printer.Print "Supplier"
    Printer.CurrentX = 650
    Printer.CurrentY = 200
    Printer.Print "Category"
    Printer.CurrentX = 950
    Printer.CurrentY = 200
    Printer.Print "Model"
    Printer.CurrentX = 1500
    Printer.CurrentY = 200
    Printer.Print "Price"
    Printer.CurrentX = 1700
    Printer.CurrentY = 200
    Printer.Print "Date"
    Printer.CurrentX = 2000
    Printer.CurrentY = 200
    Printer.Print "Invoice"
    Printer.CurrentX = 2300
    Printer.CurrentY = 200
    Printer.Print ""
    Printer.Line (200, 280)-(2400, 280)
    Printer.Font.Bold = False
    Printer.Font.Size = 10
    cury = 310
    '
    ' some code here to pull values from access tables
    '
    Printer.CurrentX = 200
    Printer.CurrentY = cury
    Printer.Print ilist(1)
    Printer.CurrentX = 650
    Printer.CurrentY = cury
    Printer.Print ilist(2)
    Printer.CurrentX = 950
    Printer.CurrentY = cury
    Printer.Print ilist(3)
    Printer.CurrentX = 1500
    Printer.CurrentY = cury
    Printer.Print ilist(4)
    Printer.CurrentX = 1700
    Printer.CurrentY = cury
    Printer.Print ilist(5)
    Printer.CurrentX = 2000
    Printer.CurrentY = cury
    Printer.Print ilist(6)
    Printer.CurrentX = 2300
    Printer.CurrentY = cury
    Printer.Print ilist(7)
    cury = cury + Printer.TextHeight("Hello") + 10
    '
    ' more database code to move to next record
    '
    Printer.EndDoc

  4. #4
    Lively Member Stupidiot's Avatar
    Join Date
    Apr 2011
    Location
    India
    Posts
    95

    Re: Garbled printing from compiled app

    Try this...This will print the same in both ide/compiled


    Private Sub Command1_Click()
    Dim sx, sy, px, py As Double
    Dim cury As Long

    sx = Screen.TwipsPerPixelX
    sy = Screen.TwipsPerPixelY
    px = Printer.TwipsPerPixelX
    py = Printer.TwipsPerPixelY

    px = sx / px
    py = sy / py

    Printer.ScaleMode = 1
    Printer.Orientation = 1

    Printer.Font.Name = "Arial"
    Printer.Font.Bold = True
    Printer.Font.Size = 12

    Printer.Print ""

    Printer.CurrentX = 200 + (200 * px)
    Printer.CurrentY = 200 + (200 * py)
    Printer.Print "Supplier"

    cury = Printer.CurrentY + Printer.TextHeight("B")
    Printer.Font.Bold = False
    Printer.Font.Size = 10

    Printer.CurrentX = 200 + (200 * px)
    Printer.CurrentY = cury
    Printer.Print "KK Supply"

    Printer.EndDoc
    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Re: Garbled printing from compiled app

    That did it. After looking at the code it was probably the original printer scaling that caused the issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width