📄 form1.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form1
Caption = "历史查询"
ClientHeight = 4575
ClientLeft = 60
ClientTop = 345
ClientWidth = 10590
ControlBox = 0 'False
LinkTopic = "Form1"
ScaleHeight = 4575
ScaleWidth = 10590
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "打印"
Height = 495
Left = 2280
TabIndex = 2
Top = 3960
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "关闭"
Height = 495
Left = 5640
TabIndex = 1
Top = 3960
Width = 1455
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 3015
Left = 0
TabIndex = 0
Top = 720
Width = 10575
_ExtentX = 18653
_ExtentY = 5318
_Version = 393216
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Unload Form1
End Sub
Private Sub Command2_Click()
Dim SQL As String
Dim Con As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Const TOP_MARGIN = 1440
Const LEFT_MARGIN = 1000
Dim BOTTOM_MARGIN As Single
MousePointer = vbHourglass
DoEvents
CheckTime0 = Str(frmPeerC.DTPicker1.Year)
CheckTime1 = Str(frmPeerC.DTPicker1.Month)
CheckTime2 = Str(frmPeerC.DTPicker1.Day)
If Con.State = 1 Then Con.Close
Con.ConnectionString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & App.Path & "\alert.mdb" & ";MODE=READWRITE;PERSIST SECURITY INFO=FALSE"
Con.Open
'SQL = "select * from alert where 年 =" & "'" & CheckTime0 & "'" & "and 月 =" & "'" & CheckTime1 & "'" & "and 日 =" & "'" & CheckTime2 & "'"
SQL = "select * from alert where 年 =" & "'" & CheckTime0 & "'"
Set Cmd.ActiveConnection = Con
Cmd.CommandText = SQL
rs.CursorLocation = adUseClient
rs.Open Cmd, , adOpenDynamic, 3
BOTTOM_MARGIN = Printer.ScaleTop + Printer.ScaleHeight - 1440
rs.MoveFirst
Printer.CurrentY = TOP_MARGIN
Printer.CurrentX = LEFT_MARGIN
Printer.Font.Size = 12
Printer.Font.Weight = 18
Printer.Print Format$("装置地址") & " " & Format$("年") & " " & Format$("月") & " " & Format$("日") & " " & Format$("时分秒") _
& " " & Format$("保护编号") & " " & Format$("事件编号") & " " & Format$("故障类型") & " " & Format$("接地母线号") & " " & Format$("接地线路号")
Do While Not rs.EOF
Printer.CurrentX = LEFT_MARGIN
Printer.Print Format$(rs!装置地址) & " " & Format$(rs!年) & " " _
& Format$(rs!月) & " " & Format$(rs!日) & " " & Format$(rs!时分秒) & _
" " & Format$(rs!保护编号) & vbTab & " " & Format$(rs!事件编号) & _
vbTab & " " & Format$(rs!故障类型) & vbTab & " " & Format$(rs!接地母线号) & vbTab & " " & Format$(rs!接地线路号)
If Printer.CurrentY >= BOTTOM_MARGIN Then
Printer.NewPage
Printer.CurrentX = TOP_MARGIN
End If
rs.MoveNext
Loop
Printer.EndDoc
MousePointer = vbDefault
End Sub
Private Sub Form_Load()
Me.Top = 1000
Me.Left = 1000
With MSFlexGrid1
.Cols = 10
.Rows = 50
.TextMatrix(0, 0) = "装置地址"
.TextMatrix(0, 1) = "年"
.TextMatrix(0, 2) = "月"
.TextMatrix(0, 3) = "日"
.TextMatrix(0, 4) = "时分秒"
'.TextMatrix(0, 5) = "秒毫秒"
.TextMatrix(0, 5) = "保护编号"
.TextMatrix(0, 6) = "事件编号"
.TextMatrix(0, 7) = "故障类型"
.TextMatrix(0, 8) = "接地母线号"
.TextMatrix(0, 9) = "接地线路号"
.ColAlignment(0) = 4
.ColAlignment(1) = 4
.ColAlignment(2) = 4
.ColAlignment(3) = 4
.ColAlignment(4) = 4
.ColAlignment(5) = 4
.ColAlignment(6) = 4
.ColAlignment(7) = 4
.ColAlignment(8) = 4
.ColAlignment(9) = 4
.ColWidth(0) = 1000
.ColWidth(1) = 800
.ColWidth(2) = 800
.ColWidth(3) = 800
.ColWidth(4) = 1400
.ColWidth(5) = 1000
.ColWidth(6) = 1000
.ColWidth(7) = 1000
.ColWidth(8) = 1200
.ColWidth(9) = 1200
End With
For ii = 1 To 29
For jj = 0 To 5
MSFlexGrid1.TextMatrix(ii, jj) = ""
Next jj
Next ii
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -