📄 frmprint.frm
字号:
VERSION 5.00
Begin VB.Form Frmprint
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H80000005&
BorderStyle = 0 'None
Caption = "打印凭证"
ClientHeight = 4470
ClientLeft = 5220
ClientTop = 3165
ClientWidth = 5265
LinkTopic = "Form8"
ScaleHeight = 298
ScaleMode = 3 'Pixel
ScaleWidth = 351
ShowInTaskbar = 0 'False
Begin Project1.xp_canvas xp_canvas1
Height = 4455
Left = 0
TabIndex = 0
Top = 0
Width = 5175
_ExtentX = 9128
_ExtentY = 7858
Caption = "打印凭证"
Icon = "Frmprint.frx":0000
Begin Project1.xpcmdbutton Command2
Height = 495
Left = 2640
TabIndex = 7
Top = 3360
Width = 1575
_ExtentX = 2778
_ExtentY = 873
Caption = "退 出"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin Project1.xpcmdbutton Command1
Height = 495
Left = 600
TabIndex = 6
Top = 3360
Width = 1455
_ExtentX = 2566
_ExtentY = 873
Caption = "打印借书凭证"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Frame Frame2
Height = 1455
Left = 120
TabIndex = 4
Top = 1560
Width = 4935
Begin VB.Label Label2
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 960
TabIndex = 5
Top = 360
Width = 2895
End
End
Begin VB.Frame Frame1
Height = 1095
Left = 120
TabIndex = 1
Top = 480
Width = 4935
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1920
TabIndex = 3
Top = 240
Width = 2775
End
Begin VB.Label Label1
Caption = "读者工号:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 2
Top = 240
Width = 1455
End
End
Begin Project1.xptopbuttons xptopbuttons2
Height = 315
Left = 4440
Top = 120
Width = 315
_ExtentX = 556
_ExtentY = 556
Value = 2
End
Begin Project1.xptopbuttons xptopbuttons1
Height = 315
Left = 4800
Top = 120
Width = 315
_ExtentX = 556
_ExtentY = 556
End
End
End
Attribute VB_Name = "Frmprint"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'图书借阅凭条打印功能
Private Sub Command1_Click() '点击打印借书凭证按钮
On Error GoTo errhandle
Dim sqltxt, printtile, printtext As String
Dim rst1 As ADODB.Recordset
Dim rst2 As ADODB.Recordset
Set rst1 = New ADODB.Recordset
If Text1.Text = "" Then '读者工号栏为空
frmMsg.Show
frmMsg.notice.Visible = True
frmMsg.Text1.Text = "请输入读者工号!"
Exit Sub
End If
sqltxt = "select * from record where [工号]='" & Trim(Text1.Text) & "'" '去除文本框的空格,从表中查找工号
rst1.Open sqltxt, con, 1, 3
If rst1.RecordCount > 0 Then '如果有记录,则显示第一条
rst1.MoveFirst
Else
frmMsg.Show
frmMsg.error.Visible = True
frmMsg.Text1.Text = "对不起,没有此用户记录!"
Exit Sub
End If
'打印标题定义
printtile = Space(100) & "工号" & Space(10) & "书名 " & Space(25) & "借书时间"
'打印数据付值(打印某一个人的所有借阅图书信息凭条)
Do While (Not rst1.EOF)
sqltext = "select * from book where [图书编码]='" & rst1![图书编码] & "'"
Set rst2 = New ADODB.Recordset
rst2.Open sqltext, con, 1, 3
If rst2.RecordCount <= 0 Then '如果没有记录,则报错
Label2.Caption = "打印失败,借阅数据与图书数据不匹配!"
Exit Sub
End If
printtext = printtext & Space(100) & rst1![工号] & Space(10) & rst2![图书名称] & Space(20) & str(rst1![借阅时间]) & Chr(13) & Chr(10)
Set rst2 = Nothing
rst1.MoveNext
Loop
Printer.Print printtile
Printer.Print printtext
Label2.Caption = "打印成功!"
Set rst1 = Nothing
Exit Sub
errhandle:
frmMsg.Show
frmMsg.error.Visible = True
frmMsg.Text1.Text = "没有发现打印机,请先安装打印机!"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub xptopbuttons1_Click()
Unload Me
End Sub
Private Sub xptopbuttons2_Click()
Me.WindowState = 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -