📄 form1.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 8685
ClientLeft = 165
ClientTop = 855
ClientWidth = 12225
LinkTopic = "Form1"
ScaleHeight = 8685
ScaleWidth = 12225
StartUpPosition = 3 'Windows Default
Begin MSAdodcLib.Adodc Adodc1
Height = 735
Left = 8640
Top = 6720
Width = 2295
_ExtentX = 4048
_ExtentY = 1296
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3855
Left = 120
TabIndex = 9
Top = 1800
Width = 11055
_ExtentX = 19500
_ExtentY = 6800
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.ComboBox Combo4
Height = 315
Left = 120
TabIndex = 8
Text = "选择参数表"
Top = 840
Width = 1815
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 7320
Top = 6960
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command1
Caption = "查 表"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1215
Left = 10320
TabIndex = 7
Top = 360
Width = 1575
End
Begin VB.TextBox Text2
Height = 615
Left = 2640
TabIndex = 6
Top = 7800
Width = 2295
End
Begin VB.TextBox Text1
Height = 615
Left = 2640
TabIndex = 5
Top = 6720
Width = 2295
End
Begin VB.ComboBox Combo3
Height = 315
Left = 7680
TabIndex = 2
Text = "请选择精度等级"
Top = 840
Width = 2055
End
Begin VB.ComboBox Combo2
Height = 315
Left = 4920
TabIndex = 1
Text = "请选择法向系数"
Top = 840
Width = 2055
End
Begin VB.ComboBox Combo1
Height = 315
Left = 2520
TabIndex = 0
Text = "请选择分度圆直径"
Top = 840
Width = 2055
End
Begin VB.Label Label3
Caption = "参数表:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 3
Left = 360
TabIndex = 13
Top = 240
Width = 1335
End
Begin VB.Label Label3
Caption = "法向系数:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 2
Left = 5400
TabIndex = 12
Top = 240
Width = 1335
End
Begin VB.Label Label3
Caption = "精度等级:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 8160
TabIndex = 11
Top = 240
Width = 1335
End
Begin VB.Label Label3
Caption = "分度圆直径:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 2760
TabIndex = 10
Top = 240
Width = 1335
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "基节极限偏差:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 240
TabIndex = 4
Top = 7680
Width = 1815
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "齿形公差:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 240
TabIndex = 3
Top = 6720
Width = 1815
End
Begin VB.Menu Start
Caption = "开始"
Begin VB.Menu SelectTbl
Caption = "选择数据库"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim DBpath As String
Dim connStr As String
Dim selectStr As String
Dim i As Integer
Dim txt As String
Private Sub Combo1_Click()
Combo2.Enabled = True
txt = Combo2.Text
Combo2.Clear
Combo2.Text = txt
' On Error GoTo errHandle:
rs1.CursorLocation = adUseClient
rs1.LockType = adLockPessimistic
rs1.ActiveConnection = conn
selectStr = "select distinct modulus from " & Combo4.Text & " where DiameterLH = " & "'" & Combo1.Text & "'"
rs1.Open selectStr
For i = 0 To rs1.RecordCount - 1
Combo2.AddItem rs1.Fields("modulus")
rs1.MoveNext
Next i
rs1.Close
'errHandle:
End Sub
Private Sub Combo2_Click()
Combo3.Enabled = True
txt = Combo3.Text
Combo3.Clear
Combo3.Text = txt
' On Error GoTo errHandle:
rs1.CursorLocation = adUseClient
rs1.LockType = adLockPessimistic
rs1.ActiveConnection = conn
selectStr = "select distinct precision from " & Combo4.Text & " where DiameterLH = " & "'" & Combo1.Text & "'" & " and modulus = " & "'" & Combo2.Text & "'"
rs1.Open selectStr
For i = 0 To rs1.RecordCount - 1
Combo3.AddItem rs1.Fields("precision")
rs1.MoveNext
Next i
rs1.Close
'errHandle:
End Sub
Private Sub Combo3_Click()
Command1.Enabled = True
' On Error GoTo errHandle:
'errHandle:
End Sub
Private Sub Combo4_Click()
Combo1.Enabled = True
txt = Combo1.Text
Combo1.Clear
Combo1.Text = txt
On Error GoTo errHandle:
rs1.CursorLocation = adUseClient
rs1.LockType = adLockPessimistic
rs1.ActiveConnection = conn
selectStr = "select distinct DiameterLH from " & Combo4.Text
rs1.Open selectStr
For i = 0 To rs1.RecordCount - 1
Combo1.AddItem rs1.Fields("DiameterLH")
rs1.MoveNext
Next i
rs1.Close
errHandle:
End Sub
Private Sub Command1_Click()
Text1.Enabled = True
Text2.Enabled = True
rs1.CursorLocation = adUseClient
rs1.LockType = adLockPessimistic
rs1.ActiveConnection = conn
selectStr = "select * from " & Combo4.Text & " where DiameterLH = " & "'" & Combo1.Text & "'" & " and modulus = " & "'" & Combo2.Text & "'" & " and precision = " & "'" & Combo3.Text & "'"
rs1.Open selectStr
Text1.Text = rs1.Fields("result(gc)").Value
Text2.Text = rs1.Fields("result(pc)").Value
Adodc1.RecordSource = selectStr
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
rs1.Close
End Sub
Private Sub Form_Load()
Adodc1.Visible = False
Command1.Enabled = False
Combo1.Enabled = False
Combo2.Enabled = False
Combo3.Enabled = False
Combo4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
End Sub
Private Sub SelectTbl_Click()
Dim Db As Database
Dim Tdf As TableDef
On Error GoTo errHandle:
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
DBpath = CommonDialog1.FileName
connStr = "provider=microsoft.jet.oledb.4.0;data source= " & DBpath
Set Db = OpenDatabase(DBpath)
conn.Open connStr
For Each Tdf In Db.TableDefs
Combo4.AddItem Tdf.Name
Next
Combo4.Enabled = True
Adodc1.ConnectionString = connStr
errHandle:
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -