?? form1.frm
字號:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1
Caption = "SQL使用技巧-數據查詢、排序"
ClientHeight = 5430
ClientLeft = 60
ClientTop = 345
ClientWidth = 10770
LinkTopic = "Form1"
ScaleHeight = 5430
ScaleWidth = 10770
StartUpPosition = 1 '所有者中心
Begin VB.CheckBox Check2
Height = 225
Left = 435
TabIndex = 11
Top = 555
Width = 315
End
Begin VB.CheckBox Check1
Height = 225
Left = 435
TabIndex = 10
Top = 195
Width = 315
End
Begin VB.ComboBox Combo4
Height = 300
Left = 4770
TabIndex = 9
Text = "Combo4"
Top = 135
Width = 1440
End
Begin VB.Data Data2
Caption = "Data2"
Connect = "Access"
DatabaseName = "E:\理財公司\mrlc.mdb"
DefaultCursorType= 0 '缺省游標
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = -450
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "sort"
Top = 1485
Visible = 0 'False
Width = 1140
End
Begin VB.Data Data1
Connect = "Access"
DatabaseName = "E:\理財公司\mrlc.mdb"
DefaultCursorType= 0 '缺省游標
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 405
Left = -360
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "kc"
Top = 1875
Visible = 0 'False
Width = 1095
End
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "查詢"
Height = 390
Left = 6510
Style = 1 'Graphical
TabIndex = 6
Top = 315
Width = 1815
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Height = 315
Left = 4800
TabIndex = 5
Text = "*"
Top = 540
Width = 1395
End
Begin VB.ComboBox Combo1
BackColor = &H00FFFFFF&
Height = 300
ItemData = "Form1.frx":0000
Left = 2265
List = "Form1.frx":0010
Style = 2 'Dropdown List
TabIndex = 4
Top = 540
Width = 1410
End
Begin VB.CommandButton Command2
BackColor = &H00C0C0C0&
Caption = "退出"
Height = 390
Left = 8505
Style = 1 'Graphical
TabIndex = 2
Top = 315
Width = 1815
End
Begin VB.ComboBox Combo3
BackColor = &H00FFFFFF&
Height = 300
ItemData = "Form1.frx":0033
Left = 2280
List = "Form1.frx":0043
Style = 2 'Dropdown List
TabIndex = 1
Top = 150
Width = 1410
End
Begin VB.ComboBox Combo2
Height = 300
ItemData = "Form1.frx":0066
Left = 3780
List = "Form1.frx":0073
Style = 2 'Dropdown List
TabIndex = 0
Top = 540
Width = 930
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "Form1.frx":0083
Height = 4425
Left = 60
OleObjectBlob = "Form1.frx":0097
TabIndex = 3
Top = 945
Width = 10590
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "設置排序: 按"
BeginProperty Font
Name = "宋體"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 375
Left = 720
TabIndex = 8
Top = 165
Width = 3795
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "設置查找:"
BeginProperty Font
Name = "宋體"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 375
Left = 735
TabIndex = 7
Top = 495
Width = 1485
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\mrlc.mdb" '打開數據庫
Data2.DatabaseName = App.Path & "\mrlc.mdb" '打開數據庫
End Sub
Private Sub Form_Activate() '系統初始化
Combo1.Text = "產品名稱"
Combo2.Text = "like"
Combo3.Text = "產品名稱"
Combo4.AddItem ("Asc")
Combo4.AddItem ("Desc")
Combo4.Text = "Asc"
End Sub
Private Sub Command1_Click()
If Check1.Value = 0 Then
If Check2.Value = 0 Then '查詢所有數據
Data1.RecordSource = "select * from kc"
Data1.Refresh
End If
If Check2.Value = 1 Then '模糊查詢
Data1.RecordSource = "select * from kc where ((kc." & Combo1.Text & " LIKE" + Chr(34) + Text1.Text + "*" + Chr(34) + "))"
Data1.Refresh
End If
End If
If Check1.Value = 1 Then
If Check2.Value = 0 Then '查詢所有數據并排序
Data1.RecordSource = "select * from kc order by " & Combo3.Text & " " & Combo4.Text
Data1.Refresh
End If
If Check2.Value = 1 Then '模糊查詢并排序
Data1.RecordSource = "select * from kc where ((kc." & Combo1.Text & " LIKE" + Chr(34) + Text1.Text + "*" + Chr(34) + "))order by " & Combo3.Text & " " & Combo4.Text
Data1.Refresh
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -