VB 打印 每页打印多份

jainkai 2016-09-18 11:07:28
我用form.print form 打印 本来没有问题
但是我有时候需要打印多张时问题就来了
一般我要打印4张 我就放4个print form
form.print form
form.print form
form.print form
form.print form


我的程序是这样

for I= 1 TO 50
每张打印次数(根据text输入取得,一般是4-6张)
next i

也就是 1要打印4张 然后2再打印4张 。。。依次类推 直到50打印4张
这样一来就是200张 有200个请求


这样是可以的,但是我发现每一个print都向打印机发送一个请求 导致打印机列表里有N多请求
打印机打印完一个,再稍停下 接受第二个请求 。。。 效率很低。。。

请问 怎么样像WORD里那样设置好 每张打印次数后 就只发送一个请求给打印机就可以了,这样打印机可以连续打印,中间不停
...全文
1795 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
笨狗先飞 2017-08-12
  • 打赏
  • 举报
回复
你的条码是自己画的吗?直接可以向printer里画。 这是当时打二维码标签的一个程序,直接运行肯定跑不起来,方法你参考一下。 Prt Picture1 调用的话就可以在picture里做打印预览 Prt Printer 的话就调用打印机直接打印 不过这个是A4纸排版的,一页打24个标签

Private Sub Prt(ByRef P As Object)
    Dim QR As clsQRCode, RT As Integer, S As String, SN As String, B2() As Byte, Pic As StdPicture
    Dim DX As Single, DY As Single, DW As Single, DH As Single
    Dim X As Single, Y As Single, W As Single, H As Single, V As Integer, PDW As Integer
    If IsNumeric(Text1.Text) Then V = CLng(Text1.Text) Else V = 1
    Set QR = New clsQRCode
    P.ScaleMode = 6
    PDW = 1
    If TypeName(P) = "Printer" Then
        P.PrintQuality = 300
        PDW = 4
    Else
        P.Cls
    End If
    DX = 3
    DY = 3
    DW = (P.ScaleWidth - 4 * DX) / 3
    DH = (P.ScaleHeight - 9 * DY) / 8
    For RT = 0 To 23
        P.FontName = "微软雅黑"
        P.FontBold = False
        P.FontSize = 9
        Select Case RT
            Case Else
                SN = "1609" & Right(Combo1.Text, 2) & Format(V + RT, "000")
        End Select
        S = "XXXXXX" & vbCrLf
        S = S & SN & vbCrLf
        S = S & "XXXX公司"
        ReDim B2(Len(S) * 3 + 64)
        QR.Encode B2, WideCharToMultiByte(CP_UTF8, 0, ByVal StrPtr(S), Len(S), B2(0), UBound(B2), ByVal 0, ByVal 0)
        Set Pic = QR.Encode(B2, WideCharToMultiByte(CP_UTF8, 0, ByVal StrPtr(S), Len(S), B2(0), UBound(B2), ByVal 0, ByVal 0))
        W = P.ScaleX(Pic.Width, vbHimetric, vbMillimeters)
        H = P.ScaleY(Pic.Height, vbHimetric, vbMillimeters)
        X = DX + (RT Mod 3) * (DX + DW) + 3
        Y = DY + (RT \ 3) * (DY + DH) + (DH - H) / 2
        P.PaintPicture Pic, X, Y
        
        X = X + 2 + W

        S = "MODEL:xxxxx-13" & Mid(SN, 5, 2)
        P.CurrentX = X
        P.CurrentY = Y
        P.Print S
        
        S = "INPUT:12-36V"
        P.CurrentX = X
        P.CurrentY = Y + P.TextHeight(S)
        P.Print S
        
        S = "S/N:" & SN
        P.CurrentX = X
        P.CurrentY = Y + 2 * P.TextHeight(S)
        P.Print S
                
        Set Pic = LoadResPicture("LOGO", vbResBitmap)
        W = P.ScaleX(Pic.Width, vbHimetric, vbMillimeters)
        H = P.ScaleY(Pic.Height, vbHimetric, vbMillimeters)
        X = DX + (RT Mod 3) * (DX + DW) + 1
        Y = DY + (RT \ 3) * (DY + DH) + 1
        P.PaintPicture Pic, X, Y
        
        P.DrawWidth = PDW
        P.DrawStyle = 0
        P.Line (DX + (RT Mod 3) * (DX + DW), DY + (RT \ 3) * (DY + DH))-((1 + RT Mod 3) * (DX + DW), (1 + RT \ 3) * (DY + DH)), vbBlack, B
        
        S = "XXXXXX终端"
        P.FontBold = True
        P.FontSize = 10
        P.CurrentX = X + W + (DW - 1 - W - P.TextWidth(S)) / 2
        P.CurrentY = Y
        P.Print S
        
        S = "XXXX00056"
        P.FontBold = False
        P.FontSize = 9
        P.CurrentX = X + W + (DW - 1 - W - P.TextWidth(S)) / 2
        P.CurrentY = Y + P.TextHeight(S)
        P.Print S
        
        S = "XXXXXXX公司"
        P.FontName = "微软雅黑"
        P.FontSize = 11
        P.CurrentX = DX + (RT Mod 3) * (DX + DW) + (DW - P.TextWidth(S)) / 2
        P.CurrentY = (1 + RT \ 3) * (DY + DH) - P.TextHeight(S) * 1.8
        P.Print S
        
        S = "xxxxxx CO., LTD"
        P.FontName = "微软雅黑"
        P.FontSize = 8
        P.CurrentX = DX + (RT Mod 3) * (DX + DW) + (DW - P.TextWidth(S)) / 2
        P.CurrentY = (1 + RT \ 3) * (DY + DH) - P.TextHeight(S) * 1.1
        P.Print S
    Next
    P.DrawWidth = 1
    P.DrawStyle = 2
    P.Line (DX / 2, DY / 2)-(P.ScaleWidth - DX / 2, P.ScaleHeight - DY / 2), RGB(128, 128, 128), B
    For RT = 1 To 2
        P.Line (DX / 2 + (DW + DX) * RT, DY / 2)-(DX / 2 + (DW + DX) * RT, P.ScaleHeight - DY / 2), RGB(128, 128, 128)
    Next
    For RT = 1 To 7
        P.Line (DX / 2, DY / 2 + (DH + DY) * RT)-(P.ScaleWidth - DX / 2, DY / 2 + (DH + DY) * RT), RGB(128, 128, 128)
    Next
    If TypeName(P) = "Printer" Then P.EndDoc
    Set QR = Nothing
End Sub
jainkai 2017-08-12
  • 打赏
  • 举报
回复
引用 5 楼 bakw 的回复:
Printer.Copies = 4 form.printform 四份就出来了
这个是不是四份就一样了啊 我打的是不一样的,里面有个条码,打一张条码号+1
赵4老师 2017-08-11
  • 打赏
  • 举报
回复
去年一滴相思泪,今年方流到腮边。
笨狗先飞 2017-08-11
  • 打赏
  • 举报
回复
Printer.Copies = 4 form.printform 四份就出来了
笨狗先飞 2017-08-11
  • 打赏
  • 举报
回复
打印之前加一句 Printer.Copies = 4 就行了
jainkai 2017-08-11
  • 打赏
  • 举报
回复
老师 ,太高深了 看不懂,,能具体讲解一下嘛
jainkai 2016-09-21
  • 打赏
  • 举报
回复
顶 UP LOOK
赵4老师 2016-09-18
  • 打赏
  • 举报
回复
Using a Print Dialog Box and Retrieving a Printer Device Context The first step in printing involves setting up the printer and obtaining a printer DC. In the sample application, the File menu contains two options, Print and Print Setup. By selecting either option, the user can configure the printer. When the user selects the Print Setup option, the Print Setup dialog box is displayed and the user can select a printer, a page orientation, a paper size, and so on. When the user selects the Print option, the Print dialog box is displayed and the user can select a range of pages, a print quality, a number of copies, and so on. The user can also display the Print Setup dialog box by clicking the Setup push button. The Print and Print Setup dialog boxes are both displayed by initializing the members of aPRINTDLG structure and calling thePrintDlg function. (For more information about displaying the Print Setup dialog box, seeCommon Dialog Box Library). In addition to retrieving user-specified data, PrintDlg can be used to obtain a printer DC by specifying the PD_RETURNDC value in the Flags member of the PRINTDLG structure. The following code sample shows how to intialize the members of the structure and to display the Print dialog box. // Initialize the PRINTDLG members. pd.lStructSize = sizeof(PRINTDLG); pd.hDevMode = (HANDLE) NULL; pd.hDevNames = (HANDLE) NULL; pd.Flags = PD_RETURNDC; pd.hwndOwner = hwnd; pd.hDC = (HDC) NULL; pd.nFromPage = 1; pd.nToPage = 1; pd.nMinPage = 0; pd.nMaxPage = 0; pd.nCopies = 1; pd.hInstance = (HANDLE) NULL; pd.lCustData = 0L; pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL; pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL; pd.lpPrintTemplateName = (LPSTR) NULL; pd.lpSetupTemplateName = (LPSTR) NULL; pd.hPrintTemplate = (HANDLE) NULL; pd.hSetupTemplate = (HANDLE) NULL; // Display the PRINT dialog box. PrintDlg(&pd);

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧