📄 newoption.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form newoption
BorderStyle = 3 'Fixed Dialog
Caption = "FG表格选择"
ClientHeight = 3285
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 5595
Icon = "newoption.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3285
ScaleWidth = 5595
ShowInTaskbar = 0 'False
Begin MSComDlg.CommonDialog CommonDialog1
Left = 240
Top = 2640
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Timer Timer1
Interval = 500
Left = 1200
Top = 2760
End
Begin VB.OptionButton Option1
Caption = "FG构成表"
Height = 375
Left = 600
TabIndex = 2
Top = 480
Width = 2535
End
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 375
Left = 4200
TabIndex = 1
Top = 2760
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "确定"
Height = 375
Left = 2640
TabIndex = 0
Top = 2760
Width = 1215
End
Begin VB.Frame Frame1
Caption = "选择表格(new)"
Height = 2055
Left = 240
TabIndex = 3
Top = 120
Width = 5175
End
Begin VB.Label spark
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 3240
TabIndex = 5
Top = 2280
Width = 1335
End
Begin VB.Label warninglable
Caption = "注意: 以上内容将被导入机型 "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 360
TabIndex = 4
Top = 2280
Width = 2895
End
End
Attribute VB_Name = "newoption"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub
Private Sub CancelButton_Click()
tableoption = 0
Unload Me
主菜单.mainGrid.Clear
主菜单.mainGrid.Visible = False
End Sub
Private Sub Form_Load()
MakeCenter newoption
tableoption = 0
Option1.Value = True
spark.Caption = savetablename
End Sub
Private Sub Option1_Click()
tableoption = 4
End Sub
Private Sub okButton_Click()
tableoption = 4
Dim CNnewexcel As New ADODB.Connection
Dim RSnewexcel As New ADODB.Recordset
Dim nameexcel As String
CommonDialog1.CancelError = True
On Error GoTo errdeal
CommonDialog1.CancelError = True
CommonDialog1.DialogTitle = "从FG表格式excel导入数据"
CommonDialog1.FileName = "*.xls"
CommonDialog1.Filter = "(xls格式)*.xls|*.xls"
CommonDialog1.ShowOpen
nameexcel = CommonDialog1.FileName
'OLE DB + ODBC Driver 方式:
'adoConnection.Open "Data Provider=MSDASQL.1;driver=Microsoft Excel Driver (*.xls);DBQ=e:\temp\book2.xls"
'Microsoft.Jet.OLEDB.4.0 方式,(建议)
With CNnewexcel
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=False;" & _
"Data Source=" & nameexcel & ";" & _
"Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"
.open
End With
RSnewexcel.open "select * from [sheet1$]", CNnewexcel, adOpenKeyset, adLockOptimistic
If RSnewexcel.EOF = True Then '判断是否为空
MsgBox "该excel表格为空白表!", vbInformation, "提醒"
Exit Sub
End If
主菜单.mainStatusBar.Panels(2).Text = "导入行数" + ",总数: " + Trim(RSnewexcel.RecordCount)
Set 主菜单.mainGrid.DataSource = RSnewexcel
Call FGGCShowGrid(RSnewexcel, 主菜单.mainGrid)
主菜单.tableinbar.Buttons("save").Enabled = True
RSnewexcel.Close
CNnewexcel.Close
Unload Me
Exit Sub
errdeal:
tableoption = 0
Exit Sub
End Sub
Public Sub FGGCShowGrid(ByVal Recordset As ADODB.Recordset, ByVal flexGrid As MSHFlexGrid)
Dim i As Integer
Dim j As Integer
With flexGrid
.Visible = True
.SelectionMode = flexSelectionByRow
.ScrollBars = flexScrollBarBoth
.FillStyle = flexFillSingle
.ScrollTrack = True
.AllowUserResizing = flexResizeColumns
.ColWidth(0) = 5
.ColWidth(1) = 500
.ColWidth(2) = 2000
.ColWidth(3) = 2000
.ColWidth(4) = 500
.ColWidth(5) = 3000
.ColWidth(6) = 4000
.ColWidth(7) = 500
.ColWidth(8) = 500
.ColWidth(9) = 500
.ColWidth(10) = 1200
.ColWidth(11) = 1000
.ColAlignmentFixed(1) = 4
.ColAlignmentFixed(2) = 4 '设置表格标题的对齐方式
.ColAlignmentFixed(3) = 4
.ColAlignmentFixed(4) = 4
.ColAlignmentFixed(5) = 4
.ColAlignmentFixed(6) = 4
.ColAlignmentFixed(7) = 4
.ColAlignmentFixed(8) = 4
.ColAlignmentFixed(9) = 4
.ColAlignmentFixed(10) = 4
.ColAlignmentFixed(11) = 4
.ColAlignment(1) = 4 '设置表格内容的对齐方式
.ColAlignment(2) = 2
.ColAlignment(3) = 2
.ColAlignment(4) = 4
.ColAlignment(5) = 2
.ColAlignment(6) = 4
.ColAlignment(7) = 4
.ColAlignment(8) = 4
.ColAlignment(9) = 4
.ColAlignment(10) = 4
.ColAlignment(11) = 4
End With
For i = 1 To flexGrid.Rows - 1
flexGrid.Row = i
For j = 1 To flexGrid.Cols - 1
flexGrid.Col = j
If (flexGrid.Row Mod 2) = 0 Then
flexGrid.CellBackColor = &HE0E0E0
Else
flexGrid.CellBackColor = vbWhite
End If
Next j
Next i
End Sub
Private Sub Timer1_Timer()
'警告闪烁功能
If spark.Visible = False Then
spark.Visible = True
Else
spark.Visible = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -