梦想鸭来拿你想要的东西啊

tlf9304 2001-07-20 03:55:16
Private Sub Dy()

With Rs
.MoveLast
ReDim strDy(.RecordCount + 8)
ReDim Fmt(.Fields.Count)
For I = 0 To .RecordCount + 7
strDy(I) = "" '初始化
Next

For I = 0 To .Fields.Count - 1
Fmt(I) = getFmt(.Fields(I).Type, CInt(.Fields(I).Size))
J = lstrlen(.Fields(I).Name & Chr(0))
If J > lstrlen(Fmt(I) & Chr(0)) Then
Fmt(I) = String(J, "@")
End If
Next

str = "┃"
str0 = "┏"
str1 = "┠"
str2 = "┗"

For I = 0 To .Fields.Count - 1
For J = 1 To Len(Fmt(I)) / 2
str0 = str0 & "━"
str1 = str1 & "─"
str2 = str2 & "━"
Next

'为减小宽度而采取以下办法
'If Len(Fmt(I)) > 40 Then
length = Len(Fmt(I)) - lstrlen(.Fields(I).Name)
If (I = .Fields.Count - 1) Then
str = str & String(Int(length / 2), " ") & .Fields(I).Name & String(Int(length / 2), " ") & "┃"
str0 = str0 & "┓"
str1 = str1 & "┨"
str2 = str2 & "┛"
Else
str = str & String(Int(length / 2), " ") & .Fields(I).Name & String(Int(length / 2), " ") & "│"
str0 = str0 & "┯"
str1 = str1 & "┼"
str2 = str2 & "┷"
End If
Next
Title = "岳阳汉森产业有限公司考勤日报表"
strDy(0) = Space(18) & Title
strDy(1) = ""
strDy(2) = Space(30) & "打印日期:" & Date
strDy(3) = str0
strDy(4) = str
strDy(5) = str1
intDc = 6

.MoveFirst
Do While Not .EOF
str = "┃"
For I = 0 To .Fields.Count - 1
If IsNull(.Fields(I).Value) Then
If (I = .Fields.Count - 1) Then
str = str & Format(" ", Fmt(I)) & "┃"
Else
str = str & Format(" ", Fmt(I)) & "│"
End If
Else
length = Len(Fmt(I)) - lstrlen(.Fields(I).Value)
If (I = .Fields.Count - 1) Then
str = str & String(length, " ") & .Fields(I).Value & "┃"
Else
str = str & String(length, " ") & .Fields(I).Value & "│"
End If
End If
Next
strDy(intDc) = strDy(intDc) & str
intDc = intDc + 1
.MoveNext
Loop
strEnd = strEnd & str2
End With

End Sub

Private Function getFmt(intType As Integer, logSize As Long) As String
Dim I As Integer
getFmt = ""

Select Case intType
Case dbBoolean
getFmt = getFmt & "\ \ \ \0;\ \ \ \1"
Case dbByte
getFmt = "@@@@"
Case dbInteger
getFmt = "@@@@@@"
Case dbLong
getFmt = "@@@@@@@@@@"
Case dbCurrency
getFmt = "@@@@@@@@@@"
Case dbSingle
getFmt = "@@@@@@@@@@"
Case dbDouble
getFmt = "@@@@@@@@@@"
Case dbDate
getFmt = "@@@@@@@@@@"
Case dbBinary
getFmt = "@@@@"
Case dbText
If logSize >= 20 Then
getFmt = String(12, "@")
Else
getFmt = String(Int((logSize + 1) / 2) * 2, "@")
End If
Case dbLongBinary
getFmt = "@@@@"
Case dbMemo
getFmt = "@@@@@@@@@@@@@@@@"
Case dbGUID
getFmt = "@@@@"
Case dbBigInt
getFmt = "@@@@@@@@@@@@@@"
Case dbVarBinary
getFmt = "@@@@"
Case dbChar
For I = 0 To CInt(logSize / 2) * 2 - 1
getFmt = getFmt & "@"
Next
Case dbNumeric
For I = 0 To CInt(logSize / 2) * 2 - 1
getFmt = getFmt & "@"
Next
Case dbDecimal
For I = 0 To CInt(logSize / 2) * 2 - 1
getFmt = getFmt & "@"
Next
Case dbFloat
getFmt = "@@@@@@@@@@"
Case dbTime
getFmt = "@@@@@@@@"
Case dbTimeStamp
getFmt = "@@@@@@@@@@"
End Select

End Function

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1 '打印
Printer.Font.Name = "楷体GB-2312"
Printer.Font.Size = 8
Printer.Font.Bold = True
Printer.Print Space(80) & strHead '打页眉

Printer.Line (0, 190)-(Me.Width, 190)

Printer.Print strDy(1) '打空行

Printer.Font.Bold = False
Printer.Font.Name = "隶书"
Printer.Font.Size = 18
Printer.Print strDy(0) '打印标题

Printer.Print strDy(1) '打印空行

Printer.Font.Name = "楷体GB-2312"
Printer.Font.Size = 14
Printer.Print strDy(2) '打印日期

Printer.Print strDy(1) '打印空行

For I = 1 To Form13.intLength '打印汇总情况
Printer.Print strHZ(I)
Printer.Print strDy(1) '打印空行
Next

Printer.Font.Name = "黑体"
Printer.Print Space(10) & "附:未正常出勤人员明细表"
intCount = 6

Printer.Font.Name = "楷体GB-2312"
'在第一页中打印表格内容
Printer.Font.Name = "宋体"
Printer.Font.Size = 12
Printer.Print Space(10) & strDy(3) '打印表头
Printer.Print Space(10) & strDy(4)

'确定每页打印表格行数
intTemp = 27 - (Form13.intLength - 1) * 4

For I = intCount To intTemp
Printer.Print Space(10) & strDy(5)
Printer.Print Space(10) & strDy(I) '打印表格内容
Next
Printer.Print Space(10) & strEnd '打印表尾
Printer.Print strDy(1)
Printer.Print Space(50) & "第" & Printer.Page & "页 " & Format(Date, "yyyy年mm月dd日") '打印页码
Printer.NewPage
intCount = I

Start1:
Printer.Font.Name = "宋体"
Printer.Font.Size = 12
Printer.Print strDy(1) '打印空行
Printer.Print Space(10) & strDy(3) '打印表头
Printer.Print Space(10) & strDy(4)

For I = intCount To intDc
If I < intCount + 28 And I < intDc Then '如果在一页内
Printer.Print Space(10) & strDy(5)
Printer.Print Space(10) & strDy(I) '打印表格内容
Else '换页
Printer.Print Space(10) & strEnd '打印表尾
Printer.Print strDy(1)
Printer.Print Space(50) & "第" & Printer.Page & "页 " & Format(Date, "yyyy年mm月dd日") '打印页码
If I = intDc Then
Exit Sub
End If
Printer.NewPage
intCount = I
GoTo Start1
End If
Next

Printer.EndDoc

End Select
End Sub
...全文
29 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

742

社区成员

发帖
与我相关
我的任务
社区描述
VB 版八卦、闲侃,联络感情地盘,禁广告帖、作业帖
社区管理员
  • 非技术类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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