请教高手! (打印机问题)

2025-01-08 03:38:03
推荐回答(4个)
回答1:

调出打印窗口它会自动让选择打印机。
打印的代码基本形同只是每个打印机的调的边距不同
好,这是我用VB 自带报表设计器的代码
Private Sub Cmdprint_Click()
'打印
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
On Error GoTo errhandler
'Dim aa As Integer
'aa = Len(Text1(21).Text)
With cdlPicture
.Flags = cdlCFBoth Or cdlCFWYSIWYG Or cdlCFScalableOnly Or cdlCFEffects
.CancelError = True
.ShowFont
End With

Dim beginfpage, endpage, numcopies, orientation, i
cdlPicture.CancelError = True
On Error GoTo errhandler
'隐藏打印到文件和份数
cdlPicture.Flags = &H100000 Or cdlPDUseDevModeCopies
cdlPicture.orientation = cdlPortrait '默认为纵向打印
cdlPicture.ShowPrinter
Printer.orientation = cdlPicture.orientation
' '下面语句设置打印的参数
Printer.FontName = cdlPicture.FontName
Printer.FontBold = cdlPicture.FontBold
Printer.FontItalic = cdlPicture.FontItalic
Printer.FontSize = cdlPicture.FontSize
Printer.FontUnderline = cdlPicture.FontUnderline
Printer.FontStrikethru = cdlPicture.FontStrikethru
'设置打印内容
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
datPrimaryRS.Recordset.MoveFirst
Dim hab As Integer
Printer.Print Frmmain.Text1(0) & " 还款记录"
Printer.Print
Printer.Print Spc(13); "日期:" & Date; Spc(3); "时间:" & Time
Printer.Print "---------------------------------------------"
Printer.Print "还款日期"; Tab; Tab; "还款额(元)"
Printer.Print "---------------------------------------------"
For hab = 1 To datPrimaryRS.Recordset.RecordCount
If datPrimaryRS.Recordset.EOF Or datPrimaryRS.Recordset.BOF Then
Exit Sub
End If
Printer.Print Text1, Tab; Text2
datPrimaryRS.Recordset.MoveNext
Next hab
frmfm.Print "---------------------------------------------"
Printer.EndDoc
Exit Sub
errhandler:
Printer.EndDoc '清空打印机
Exit Sub
End Sub
这是我用ACTIVEREPORT 报表控件的代码 设计器的NAME bb_rkckd 楼上的兄台,我不知道你用什么做表表,但是我提议你使用水晶报表或ACTIVEREPORT
With bb_rkckd
.dmmc = logouserbm
.dwmc = title_dlx
.Label2 = " " & Label4.Caption & " "
.Caption = Label4.Caption
.DataControl1.ConnectionString = conn
.DataControl1.Source = strsql
.DataControl1.Refresh

.lab_tjrq.Caption = "报表日期:" & Format(DTPicker1(0), "YYYY年MM月DD日") & "至" & Format(DTPicker1(1), "YYYY年MM月DD日")

.FID_RQ.DataField = "日期"
.FID_DH.DataField = "单号"
.FID_CK.DataField = "库房"
.FID_DW.DataField = "供应商"
.FID_JSFS.DataField = "结算方式"
.FID_JE.DataField = "金额(元)"

.JEHJ.DataField = "金额(元)"
.pagehj.DataField = "金额(元)"
.Show
End With
Command1(1).Enabled = False

回答2:

Public Function Gset_Printer_Default(sPrinterNm As String) As Boolean
Dim Ret As Long 'API戻り値
Dim Buffer As String 'バッファ
Dim strDeviceName As String 'デバイス名
Dim strDriverName As String 'ドライバー名
Dim strPrinterPort As String 'ポート名
Dim strData As String 'INIファイルに书き込むデータ
Dim intCount1 As Integer '文字列抽出用
Dim intCount2 As Integer '文字列抽出用
Gset_Printer_Default = False
'ドライバ名、ポート名の取得
Buffer = Space(1024)
Ret = GetProfileString("PrinterPorts", sPrinterNm, "", Buffer, Len(Buffer))
intCount1 = InStr(Buffer, ",")
If intCount1 > 0 Then
strDriverName = Left(Buffer, intCount1 - 1)
intCount2 = InStr(intCount1 + 1, Buffer, ",")
If intCount2 > 0 Then
strPrinterPort = Mid(Buffer, intCount1 + 1, intCount2 - intCount1 - 1)
End If
End If
'设定を更新
If strDriverName <> "" And strPrinterPort <> "" Then
strData = sPrinterNm & "," & strDriverName & "," & strPrinterPort
Ret = WriteProfileString("windows", "device", strData)
'デフォルトプリンタ设定変更の通知
'この処理を行わなければ、全てのアプリケーションは、
'変更したデフォルトプリンタを认识しません。
Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, "windows")
Gset_Printer_Default = True
End If
End Function

'这个上面是取默认打印机的代码 你只要把打印机连到你的机器上 用法和以前都是一样的!~

回答3:

机器不好我修过改连供的机器效果特差的最好别用的

回答4:

MP198改连供还可以,主要是看改连供的人的水平,另外所有佳能的机器都有一个硬伤就是废墨吸收的海绵太少,又不好外接废墨管所以废墨容易往向漏。但如果你的打印量不是很大的话还是不错的,另外就是爱普生的机器,不过要贵一些,而且现在ME330连供还不很成熟ME300机器又停产了。