?? form1.frm
字號:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1
Caption = "自動分頁的打印程序"
ClientHeight = 3405
ClientLeft = 1620
ClientTop = 1545
ClientWidth = 5625
LinkTopic = "Form1"
ScaleHeight = 3405
ScaleWidth = 5625
StartUpPosition = 1 '所有者中心
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "Form1.frx":0000
Height = 2550
Left = 210
OleObjectBlob = "Form1.frx":0014
TabIndex = 2
Top = 120
Width = 5040
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 4035
TabIndex = 1
Top = 2775
Width = 1215
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "E:\編程技巧\sjk\數(shù)據(jù)庫打印程序(會自動分頁的簡單例程)\Data.mdb"
DefaultCursorType= 0 '缺省游標(biāo)
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 390
Left = 1215
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Value"
Top = 2970
Visible = 0 'False
Width = 1800
End
Begin VB.CommandButton Command1
Caption = "打印數(shù)據(jù)"
Height = 495
Left = 2715
TabIndex = 0
Top = 2775
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\data.mdb" '設(shè)置數(shù)據(jù)庫路徑
End Sub
Private Sub Form_Activate()
DBGrid1.Columns(0).Width = 1200 '設(shè)置dbgrid列寬
DBGrid1.Columns(1).Width = 3000
End Sub
Private Sub Command1_Click() '分頁打印
Dim bottom As Single
Dim db As Database
Dim rs As Recordset
Dim dbname As String
MousePointer = vbHourglass '設(shè)置鼠標(biāo)指針為沙漏
DoEvents
dbname = App.Path
If Right$(dbname, 1) <> "\" Then dbname = dbname & "\" '判斷數(shù)據(jù)庫路徑
dbname = dbname & "data.mdb"
Set db = OpenDatabase(dbname)
Set rs = db.OpenRecordset("value", dbOpenTable)
bottom = Printer.ScaleTop + Printer.ScaleHeight - 1440 '設(shè)置紙張下邊界
rs.MoveFirst
Printer.CurrentY = 1400
Do While Not rs.EOF
Printer.CurrentX = 1400
Printer.Print Format$(rs!Year, "yyyy") & vbTab & Format$(rs!Value, "0.0000")
If Printer.CurrentY >= bottom Then
Printer.NewPage
Printer.CurrentY = 1400
End If
rs.MoveNext
Loop
rs.Close
db.Close
Printer.EndDoc '開始打印
MousePointer = vbDefault '設(shè)置默認(rèn)鼠標(biāo)指針
End Sub
Private Sub Command2_Click()
End
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -