📄 dydianfei.frm
字号:
End If
ProgressBar1.Visible = False
Label13.Caption = "文件生成,正在打印"
'─││┆┈┄┆┊┌┐└┘├┤┬┴┼╱╲「」╥ ║╧ ╫ ╨
On Error GoTo hander
MdbR.Close
Set MdbR = NdMd.OpenRecordset("select * from 电费公布库 order by 编号")
If MdbR.RecordCount = 0 Then
Exit Sub
Else
MdbR.MoveFirst
End If
dian_fei = 0#
dian_liang = 0
count_user = 0
zong_user = 0
users = 0
Screen.MousePointer = 11
head_title = pbDw & XcName & "电费公布栏(" & GzNian & " 年" & GzYue & "月份)"
With MdbR
total_page = (.RecordCount + 60) \ 61
Call printer_init
Call printer_string(0, 0, Space(32) & head_title)
Printer.Print Space(8) & "填制单位:" & XcName, Space(10) & "制表日期" & Format(Date, "long date"), Space(15) & "单位:KWH/元"
Printer.Print " ─────────────────────────┬─────────────────────────"
Printer.CurrentX = 0
Printer.Print " 编 号 户 名 本月电量 电 费 应 收 实 收 │编 号 户 名 本月电量 电 费 应 收 实 收"
Printer.Print " ─────────────────────────┼─────────────────────────"
.MoveFirst
For i = 0 To .RecordCount - 1
Printer.Print Space(5) & Left(Trim(.Fields("编号")) & Space(6), 6) & " " & Left(Trim(.Fields("户名")) & Space(10), 10 - convert_str(Trim(.Fields("户名")))) & Right(Space(8) & .Fields("本月电量"), 8) & Right(Space(8) & .Fields("电费"), 8) & Right(Space(8) & .Fields("应收"), 8) & Right(Space(8) & .Fields("实收"), 8) & " │" & Left(Trim(.Fields("编号1")) & Space(6), 6) & " " & Left(Trim(.Fields("户名1")) & Space(10), 10 - convert_str(Trim(.Fields("户名1")))) & Right(Space(8) & .Fields("本月电量1"), 8) & Right(Space(8) & .Fields("电费1"), 8) & Right(Space(8) & .Fields("应收1"), 8) & Right(Space(8) & .Fields("实收1"), 8)
' dian_liang = dian_liang + Val(.Fields!本月电量) + Val(.Fields!本2月电量1)
' dian_fei = dian_fei + Val(.Fields!电费) + Val(.Fields!电费1)
' shishou = shishou + Val(.Fields!实收) + Val(.Fields!实收1)
count_user = count_user + 1
If Not .eof Then
.MoveNext
End If
If count_user > 59 Then
Printer.Print " ─────────────────────────┴─────────────────────────"
Printer.Print Space(70) & "共" & total_page & "页" & " 第" & Printer.Page & "页"
Printer.NewPage
' dian_fei = 0#
' dian_liang = 0
count_user = 0
Call printer_string(0, 0, Space(32) & head_title)
Printer.Print Space(8) & "填制单位:" & XcName, Space(10) & "制表日期" & Format(Date, "long date"), Space(15) & "单位:KWH/元"
Printer.Print " ─────────────────────────┬─────────────────────────"
Printer.CurrentX = 0
Printer.Print " 编 号 户 名 本月电量 电 费 应 收 实 收 │编 号 户 名 本月电量 电 费 应 收 实 收"
Printer.Print " ─────────────────────────┼─────────────────────────"
End If
Next
Printer.Print " ─────────────────────────┴─────────────────────────"
Printer.Print Space(45) & "共" & total_page & "页" & " 第" & Printer.Page & "页"
End With
Printer.Print " 该台区小计:" & "共" & Label14.Caption & "只表" & " 计费电量:" & dianliang & "Kwh 电费:" & dianfei & "元 应收:" & yingshou & "元 实收:" & Format(yingshou, "0.0") & "元"
Printer.EndDoc
Screen.MousePointer = 0
MsgBox "打印结束!", vbInformation
Label13.Visible = False
Exit Sub
hander:
If Err.Number = 482 Then
MsgBox "未安装打印机或打印机错误!", vbCritical
Screen.MousePointer = 0
Exit Sub
Else
Resume Next
End If
End Sub
Private Sub Toolbar2_ButtonClick(ByVal Button As MSComctlLib.Button)
Unload Me
End Sub
Sub PrinToFile()
Dim i As Integer, total_page As Integer
Dim count_user As String, head_title As String
Dim dian_liang As Long, zong_user As Long, users As Long
Dim PrintFile As String
Dim dian_fei As Double
PrintFile = "打印事例.TXT"
If FileExists("c:\my documents\" & PrintFile) Then
Kill "c:\my documents\" & PrintFile
End If
Open "c:\my documents\" & PrintFile For Append As #1
Label13.Visible = True
Label13.Caption = "正在生成为文件......."
ProgressBar1.Visible = True
ProgressBar1.Max = 2
ProgressBar1.Min = 1
ProgressBar1.Value = 1
Call FileShenChen(60)
ProgressBar1.Value = ProgressBar1.Value + 1
If BiaoZhi = 1 Then
ProgressBar1.Visible = False
Label13.Visible = False
Exit Sub
End If
ProgressBar1.Visible = False
Label13.Caption = "文件生成,正在打印"
'─││┆┈┄┆┊┌┐└┘├┤┬┴┼╱╲「」╥ ║╧ ╫ ╨
'On Error GoTo hander
MdbR.Close
Set MdbR = NdMd.OpenRecordset("select * from 电费公布库 order by 编号")
If MdbR.RecordCount = 0 Then
Exit Sub
Else
MdbR.MoveFirst
End If
dian_fei = 0#
dian_liang = 0
count_user = 0
zong_user = 0
users = 0
Screen.MousePointer = 11
head_title = pbDw & XcName & "电费公布栏(" & GzNian & " 年" & GzYue & "月份)"
With MdbR
total_page = (.RecordCount + 60) \ 61
' Call printer_init
' Call printer_string(0, 0, Space(26) & head_title)
Print #1, Space(32) & head_title
Print #1, Space(8) & "填制单位:" & XcName, Space(10) & "制表日期:" & Format(Date, "long date"), Space(15) & "单位:KWH/元"
' Print #1, "123"
Print #1, "───────────────────────────┬─────────────────────────────"
Print #1, "编 号 户 名 本月电量 电 费 应 收 实 收 │编 号 户 名 本月电量 电 费 应 收 实 收"
Print #1, "───────────────────────────┼─────────────────────────────"
.MoveFirst
For i = 0 To .RecordCount - 1
Print #1, Left(Trim(.Fields("编号")) & Space(6), 6) & " " & Left(Trim(.Fields("户名")) & Space(10), 10 - convert_str(Trim(.Fields("户名")))) & Right(Space(8) & .Fields("本月电量"), 8) & Right(Space(9) & .Fields("电费"), 9) & Right(Space(9) & .Fields("应收"), 9) & Right(Space(10) & .Fields("实收"), 10) & " │" & Left(Trim(.Fields("编号1")) & Space(6), 6) & " " & Left(Trim(.Fields("户名1")) & Space(10), 10 - convert_str(Trim(.Fields("户名1")))) & Right(Space(9) & .Fields("本月电量1"), 9) & Right(Space(9) & .Fields("电费1"), 9) & Right(Space(9) & .Fields("应收1"), 9) & Right(Space(9) & .Fields("实收1"), 9)
count_user = count_user + 1
If Not .eof Then
.MoveNext
End If
If count_user > 59 Then
Print #1, "───────────────────────────┴─────────────────────────────"
Print #1, Space(65) & "共" & total_page & "页" & " 第" & Printer.Page & "页"
Printer.NewPage '
dian_fei = 0#
dian_liang = 0
count_user = 0
'Call printer_string(0, 0, Space(23) & head_title)
Print #1, Space(32) & head_title
Print #1, Space(8) & "填制单位:" & XcName, Space(10) & "制表日期:" & Format(Date, "long date"), Space(15) & "单位:KWH/元"
Print #1, "───────────────────────────┬─────────────────────────────"
Print #1, "编 号 户 名 本月电量 电 费 应 收 实 收 │编 号 户 名 本月电量 电 费 应 收 实 收"
Print #1, "───────────────────────────┼─────────────────────────────"
End If
Next
Print #1, "───────────────────────────┴─────────────────────────────"
Print #1, Space(45) & "共" & total_page & "页" & " 第" & Printer.Page & "页"
End With
Printer.EndDoc '
Screen.MousePointer = 0
Close #1
MsgBox "打印结束!", vbInformation
Label13.Visible = False
Exit Sub
hander:
If Err.Number = 482 Then
MsgBox "未安装打印机或打印机错误!", vbCritical
Screen.MousePointer = 0
Exit Sub
Else
Resume Next
End If
End Sub
Sub DaYin()
Dim i As Integer
Dim count_user As String
Dim dian_liang As Long
Dim dian_fei As Double
Dim head_title As String
Dim zong_user As Long
Dim users As Long
Dim total_page As Integer
Dim mydb As New ADODB.Connection
'─││┆┈┄┆┊┌┐└┘├┤┬┴┼╱╲「」|]
'|┴ ┼ ┬ ┤└ ├ ┘ ┌┐│
On Error GoTo hander
dian_fei = 0#
dian_liang = 0
count_user = 0
zong_user = 0
users = 0
Screen.MousePointer = 11
Label13.Visible = True
Label13.Caption = "正在生成为文件......."
ProgressBar1.Visible = True
ProgressBar1.Max = 2
ProgressBar1.Min = 1
ProgressBar1.Value = 1
Call FileShenChen(37)
ProgressBar1.Value = ProgressBar1.Value + 1
If BiaoZhi = 1 Then
ProgressBar1.Visible = False
Label13.Visible = False
Exit Sub
End If
ProgressBar1.Visible = False
Label13.Caption = "文件生成,正在打印"
MdbR.Close
Set MdbR = NdMd.OpenRecordset("select * from 电费公布库 order by 编号")
'Set MdbR = NdMd.OpenRecordset("select sum(val(本月电量)+val(本月电量1)) as a,sum(val(电费)+val(电费1)) as b,sum(val(应收)+val(应收1)) as c,sum(val(实收)+val(实收1)) as d from 电费公布库")
If MdbR.RecordCount <> 0 Then
MdbR.MoveFirst
Else
Exit Sub
End If
Call Print_CuSiHu
' Printer.Font.Bold = True
' Printer.Font.Name = "楷体_GB2312"
Printer.Font.Size = 16
head_title = pbDw & XzName & XcName & "电费公布栏(" & GzNian & " 年" & GzYue & "月份)"
total_page = (MdbR.RecordCount + 36) \ 37
'Call printer_init
Call printer_string(0, 0, Space(6) & head_title)
Printer.Font.Size = 9
'─││┆┈┄┆┊┌┐└┘├ ┤┬ ┴ ┼╱╲「」╥ ║╧ ╫ ╨
Printer.Print Space(5) & "填制单位:" & XcName, Space(10) & "制表日期" & Format(Date, "long date"), Space(15) & "单位:KWH/元"
Printer.Print "┌───┬─────┬────┬────┬────┬────┬───┬─────┬────┬────┬────┬────┐"
Printer.Print "│编 号│ 户 名 │本月电量│ 电 费 │ 应 收 │ 实 收 │编 号│ 户 名 │本月电量│ 电 费 │ 应 收 │ 实 收 │"
Printer.Print "├───┼─────┼────┼────┼────┼────┼───┼─────┼────┼────┼────┼────┤"
For i = 0 To MdbR.RecordCount - 1
If count_user < 36 And i <> MdbR.RecordCount - 1 Then
With MdbR
Printer.Print "│" & Left(Trim(.Fields("编号")) & Space(6), 6) & "│" & Left(Trim(.Fields("户名")) & Space(10), 10 - convert_str(Trim(.Fields("户名")))) & "│" & Right(Space(8) & .Fields("本月电量"), 8) & "│" & Right(Space(8) & .Fields("电费"), 8) & "│" & Right(Space(8) & .Fields("应收"), 8) & "│" & Right(Space(8) & .Fields("实收"), 8) & "│" & Left(Trim(.Fields("编号1")) & Space(6), 6) & "│" & Left(Trim(.Fields("户名1")) & Space(10), 10 - convert_str(Trim(.Fields("户名1")))) & "│" & Right(Space(8) & .Fields("本月电量1"), 8) & "│" & Right(Space(8) & .Fields("电费1"), 8) & "│" & Right(Space(8) & .Fields("应收1"), 8) & "│" & Right(Space(8) & .Fields("实收1"), 8) & "│"
Printer.Print "├───┼─────┼────┼────┼────┼────┼───┼─────┼────┼────┼────┼────┤"
count_user = count_user + 1
End With
Else
With MdbR
Printer.Print "│" & Left(Trim(.Fields("编号")) & Space(6), 6) & "│" & Left(Trim(.Fields("户名")) & Space(10), 10 - convert_str(Trim(.Fields("户名")))) & "│" & Right(Space(8) & .Fields("本月电量"), 8) & "│" & Right(Space(8) & .Fields("电费"), 8) & "│" & Right(Space(8) & .Fields("应收"), 8) & "│" & Right(Space(8) & .Fields("实收"), 8) & "│" & Left(Trim(.Fields("编号1")) & Space(6), 6) & "│" & Left(Trim(.Fields("户名1")) & Space(10), 10 - convert_str(Trim(.Fields("户名1")))) & "│" & Right(Space(8) & .Fields("本月电量1"), 8) & "│" & Right(Space(8) & .Fields("电费1"), 8) & "│" & Right(Space(8) & .Fields("应收1"), 8) & "│" & Right(Space(8) & .Fields("实收1"), 8) & "│"
Printer.Print "└───┴─────┴────┴────┴────┴────┴───┴─────┴────┴────┴────┴────┘"
count_user = count_user + 1
Printer.Print Space(45) & "共" & total_page & "页" & " 第" & Printer.Page & "页"
If i <> .RecordCount - 1 Then
Printer.NewPage
count_user = 0
dian_fei = 0#
dian_liang = 0
Printer.Font.Size = 16
Call printer_string(0, 0, Space(6) & head_title)
Printer.Font.Size = 9
Printer.Print Space(5) & "填制单位:" & XcName, Space(10) & "制表日期" & Format(Date, "long date"), Space(15) & "单位:KWH/元"
Printer.Print "┌───┬─────┬────┬────┬────┬────┬───┬─────┬────┬────┬────┬────┐"
Printer.Print "│编 号│ 户 名 │本月电量│ 电 费 │ 应 收 │ 实 收 │编 号│ 户 名 │本月电量│ 电 费 │ 应 收 │ 实 收 │"
Printer.Print "├───┼─────┼────┼────┼────┼────┼───┼─────┼────┼────┼────┼────┤"
End If
End With
End If
If Not MdbR.eof Then
MdbR.MoveNext
End If
Next
Printer.EndDoc
Screen.MousePointer = 0
MsgBox "打印完毕!", vbInformation
Label13.Visible = False
Exit Sub
hander:
If Err.Number = 482 Then
MsgBox "打印机错误!", vbCritical
Screen.MousePointer = 0
Exit Sub
Else
Resume Next
End If
End Sub
Sub Print_CuSiHu()
Printer.ColorMode = 1
Printer.CurrentX = 0
Printer.CurrentY = 0
Printer.Duplex = 1
Printer.Orientation = 1
Printer.ScaleLeft = 0
Printer.ScaleTop = 0
Printer.ScaleHeight = 67
Printer.ScaleWidth = 100
Printer.Font.Name = "楷体_GB2312"
Printer.Font.Italic = False
Printer.Font.Bold = True
Printer.Font.Underline = False
Printer.Font.Weight = 9
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -