⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 本文件包含200个visual baisc实例
💻 FRM
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1 
   Caption         =   "打印DBGrid表格里的数据"
   ClientHeight    =   4320
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8025
   LinkTopic       =   "Form1"
   ScaleHeight     =   4320
   ScaleWidth      =   8025
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command2 
      Caption         =   "打印"
      Height          =   375
      Left            =   2430
      TabIndex        =   2
      Top             =   3735
      Width           =   2610
   End
   Begin VB.CommandButton Command1 
      Caption         =   "退出"
      Height          =   360
      Left            =   5310
      TabIndex        =   1
      Top             =   3765
      Width           =   2550
   End
   Begin MSDBGrid.DBGrid DBGrid1 
      Bindings        =   "Form1.frx":0000
      Height          =   3495
      Left            =   285
      OleObjectBlob   =   "Form1.frx":0014
      TabIndex        =   0
      Top             =   180
      Width           =   7530
   End
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   375
      Left            =   270
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   ""
      Top             =   -75
      Visible         =   0   'False
      Width           =   1350
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim db As Database
Dim tb As TableDef
Dim PrintString As String
Private Sub Command2_Click()
  Dim I As Long, J As Long, K As Long
  Dim PrintStr As String
  For I = 0 To Data1.Recordset.RecordCount - 1
      If K = DBGrid1.VisibleRows Then
         DBGrid1.Scroll 0, DBGrid1.VisibleRows
         K = 0
      End If
      For J = 0 To DBGrid1.Columns.Count - 1
          PrintString = PrintString & DBGrid1.Columns(J).CellText(DBGrid1.RowBookmark(K)) & "/"
      Next
      Printer.Print PrintString
      PrintString = ""
      K = K + 1
      DoEvents
  Next
End Sub
Private Sub Form_Load()
  Data1.DatabaseName = App.Path & "\sj.mdb"
  Data1.Connect = ";pwd=" & 111
  Data1.RecordSource = "sy"
End Sub
Private Sub Command1_Click()
  End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -