📄 frmdriverlist.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmdriverlist
Caption = "司机列表"
ClientHeight = 6765
ClientLeft = 2520
ClientTop = 2040
ClientWidth = 10245
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 6765
ScaleWidth = 10245
Begin VB.CommandButton Command2
Caption = "报 表"
Height = 375
Left = 1680
TabIndex = 3
Top = 120
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "导出数据"
Height = 375
Left = 360
TabIndex = 2
Top = 120
Width = 1215
End
Begin MSFlexGridLib.MSFlexGrid msglist
Height = 4815
Left = 360
TabIndex = 0
Top = 720
Width = 9135
_ExtentX = 16113
_ExtentY = 8493
_Version = 393216
Cols = 10
End
Begin VB.Label Lbltitle
Alignment = 2 'Center
Caption = "司 机 列 表"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2760
TabIndex = 1
Top = 240
Width = 2655
End
End
Attribute VB_Name = "frmdriverlist"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public txtsql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
Private Sub Command1_Click()
Call excldata
End Sub
Private Sub Command2_Click()
Dim oSHT As LLanV.LLAN_VIEW
Dim aLab() As String
Dim aTxt() As String
Dim aPer() As Double
Dim nLen As Long
Dim I As Long
ReDim aLab(3)
ReDim aTxt(3)
ReDim aPer(3)
nLen = 4
For I = 0 To 3
aPer(I) = 0.33 ''各项的宽度权数
Next
Dim sConDesc As String
sConDesc = "FileDSN=myconnection.dsn;UID=sa;PWD="
Set oSHT = New LLanV.LLAN_VIEW
Call oSHT.OnSetCN_STR(sConDesc)
Call oSHT.OnSetSQL("select * from driver")
'Call oSHT.OnSetPath(App.Path & "\IMG")
Call oSHT.OnRun("司机信息统计表", aLab, aTxt, aPer, 0)
End Sub
Private Sub Form_Load()
showtitle
showdata
Call Form_Resize
flagdEdit = True
'flagtoexcel = 3
End Sub
Public Sub showtitle()
Dim I As Integer
With msglist
.Cols = 10 '列数为10
.TextMatrix(0, 1) = "执照号码"
.TextMatrix(0, 2) = "姓名"
.TextMatrix(0, 3) = "性别"
.TextMatrix(0, 4) = "出生年月"
.TextMatrix(0, 5) = "家庭住址"
.TextMatrix(0, 6) = "考取驾照时间"
.TextMatrix(0, 7) = "准驾车型"
.TextMatrix(0, 8) = "有效期起始日期"
.TextMatrix(0, 9) = "有效期结束日期"
.FixedRows = 1
For I = 0 To 9
.ColAlignment(I) = 0
Next I
.FillStyle = flexFillRepeat '对齐单元格
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.ColWidth(0) = 300 '设置单元格大小
.ColWidth(1) = 1000
.ColWidth(2) = 1000
.ColWidth(3) = 600
.ColWidth(4) = 1000
.ColWidth(5) = 3000
.ColWidth(6) = 1200
.ColWidth(7) = 1000
.ColWidth(8) = 1400
.ColWidth(9) = 1400
.Row = 1
End With
End Sub
Public Sub showdata()
Dim I As Integer
Dim j As Integer
If txtsql = "" Then
txtsql = "select * from driver"
Set mrc = ExecuteSQL(txtsql, msgtext)
Else
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF = True Then
MsgBox "找不到你想要做的数据", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
End If
With msglist
.Rows = 1
Do While Not mrc.EOF
.Rows = .Rows + 1
For I = 1 To mrc.Fields.Count
If mrc.Fields(I - 1).Type = adDBDate Then
.TextMatrix(.Rows - 1, I) = Format(mrc.Fields(I - 1) & "", "yyyy-mm-dd")
Else
.TextMatrix(.Rows - 1, I) = mrc.Fields(I - 1) & ""
End If
Next I
mrc.MoveNext
Loop
End With
' Call Form_Resize
' mrc.Close
End Sub
Private Sub Form_Resize()
If Me.WindowState <> vbMinimized And fMainForm.WindowState <> vbMinimized Then
If Me.ScaleHeight < 10 * Lbltitle.Height Then '边界处理
Exit Sub
End If
If Me.ScaleWidth < Lbltitle.Width + Lbltitle.Width / 2 Then
Exit Sub
End If
Lbltitle.Top = Lbltitle.Height '控制控件的位置
Lbltitle.Left = (Me.Width - Lbltitle.Width) / 2
msglist.Top = Lbltitle.Top + Lbltitle.Height + Lbltitle.Height / 2
msglist.Width = Me.ScaleWidth - 200
msglist.Left = Me.ScaleLeft + 100
msglist.Height = Me.ScaleHeight - msglist.Top - 200
End If
End Sub
Public Sub FormClose()
flagdEdit = False
gintdMode = 0
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
flagdEdit = False
gintdMode = 0
Unload Me
' flagtoexcel = 0
End Sub
Private Sub msglist_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 And Shift = 0 Then
PopupMenu fMainForm.driverm
End If
End Sub
Public Sub excldata()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim I As Long, j As Long
On Error GoTo ErrorHandle
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
For I = 0 To msglist.Rows - 1
For j = 0 To msglist.Cols - 1
xlSheet.Cells(I + 1, j + 1).Value = msglist.TextMatrix(I, j)
Next j
Next I
xlSheet.Application.Visible = True
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Exit Sub
ErrorHandle:
MsgBox "错误:" & Err.Number & vbCrLf & Err.Description, vbOKOnly, "运行错误!"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -