?? mod_print.bas
字號:
Attribute VB_Name = "Mod_Print"
Option Explicit
Private Type Type_Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private mrect As Type_Rect
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As Type_Rect, ByVal wFormat As Long) As Long
Private Const DT_RIGHT = &H2
Private Const DT_TOP = &H0
Private Const DT_CENTER = &H1
Private Const DT_LEFT = &H0
Private Const DT_NOCLIP = &H100
Public mScreenID As Long, mPrintID As Long, mBillID As Long, mBillView As String
Public mEmptyBill As Boolean
Public mPageWidth As Double, mPageHeight As Double, mLandScape As Boolean
'頁邊距
Public mPageLeft As Double, mPageRight As Double, mPageUp As Double, mPageDown As Double
Public mPageScale As Double, mFontScale As Double
Public mrowcount As Integer, mRowHeight As Double, mColWidth As Double, mcolcount As Double
Public mOrderBy As String, mGroupBy As String, mBillType As Integer
Public mTotalPage As Integer
Public Sub PreViewBill(msID As Long, PrintID As Long, BillID As Long, Optional nCount As Integer = -1, Optional PreView As Boolean = True, Optional EmptyBill As Boolean = False)
On Error GoTo Err
mEmptyBill = EmptyBill
mBillID = BillID
Call LoadBill(nCount)
If EmptyBill Or PreView Then
Call BillPreView
Else
Call BillPrint
End If
Exit Sub
Err:
MsgBox "錯誤:" & Err.Number & " " & Err.Description & " " & Err.Source, vbExclamation, Err.Number
End Sub
Public Sub LoadBill(Optional nCount As Integer = -1)
Dim i As Integer, m As Integer, n As Integer, strValue As String, strsql As String
If Not mEmptyBill Then
Else
mTotalPage = 1
End If
Exit Sub
End Sub
Public Sub BillPrint()
Dim i As Integer
On Error GoTo error
For i = 1 To mTotalPage
ShowBillData i, True: Printer.EndDoc
Next
Exit Sub
error:
MsgBox " 打印錯誤!" & vbCrLf & Err.Description, vbExclamation, App.EXEName
End Sub
Public Sub BillPreView()
'On Error GoTo error
Exit Sub
error:
MsgBox "打印錯誤!" & vbCrLf & Err.Description, vbExclamation, App.EXEName
End Sub
'計算總頁數
Public Function TotalPage() As Integer
End Function
Private Sub PrintText(PrintObj As Object, CX As Single, CY As Single, ByVal strPrint As String)
Dim UFormat As Long, strFormat As String
Dim F1 As Boolean, F2 As Boolean, F3 As Boolean, F4 As Boolean
On Error GoTo error
If strPrint = "" Then Exit Sub
If strFormat <> "" Then
F1 = InStr(strFormat, "[去小數點]")
strFormat = Replace(strFormat, "[去小數點]", "", 1, -1, vbTextCompare)
F2 = InStr(strFormat, "[大寫金額]")
strFormat = Replace(strFormat, "[大寫金額]", "", 1, -1, vbTextCompare)
F3 = InStr(strFormat, "[大寫數字]")
strFormat = Replace(strFormat, "[大寫數字]", "", 1, -1, vbTextCompare)
F4 = InStr(strFormat, "[僅數字]")
strFormat = Replace(strFormat, "[僅數字]", "", 1, -1, vbTextCompare)
strPrint = Format(strPrint, strFormat)
If F1 Then
strPrint = Replace(strPrint, ".", "", 1, -1, vbTextCompare)
ElseIf F2 Then
End If
End If
With PrintObj
mrect.Left = .ScaleX(CX, .ScaleMode, vbPixels)
mrect.Top = .ScaleY(CY, .ScaleMode, vbPixels)
DrawText .hdc, strPrint, -1, mrect, UFormat
End With
Exit Sub
error:
MsgBox "打印錯誤!" & vbCrLf & Err.Description, vbExclamation, , vbExclamation, App.EXEName
End Sub
Public Sub ShowBillData(Page As Integer, Optional OutPutToPrinter As Boolean = False)
Dim PrintObj As Object
Dim i As Integer, j As Integer, SumField As String, SumData As Double, strValue As String
On Error GoTo error
Exit Sub
error:
MsgBox "打印錯誤!" & vbCrLf & Err.Description, vbExclamation, App.EXEName
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -