📄 form17.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form Form17
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Caption = "查询窗口"
ClientHeight = 7215
ClientLeft = 45
ClientTop = 345
ClientWidth = 6570
LinkTopic = "Form17"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7215
ScaleWidth = 6570
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame4
BackColor = &H00FFC0C0&
Height = 615
Left = 1440
TabIndex = 24
Top = 3960
Width = 3015
Begin VB.OptionButton Option6
BackColor = &H00FFC0C0&
Caption = "或者"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1920
TabIndex = 26
Top = 240
Width = 855
End
Begin VB.OptionButton Option5
BackColor = &H00FFC0C0&
Caption = "并且"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 25
Top = 240
Value = -1 'True
Width = 855
End
End
Begin VB.Frame Frame3
BackColor = &H00FFC0C0&
Height = 1515
Left = 465
TabIndex = 17
Top = 4935
Width = 5700
Begin VB.ComboBox Cbo2
BackColor = &H00FFC0FF&
Height = 300
Left = 4080
TabIndex = 23
Text = "Combo1"
Top = 360
Width = 1485
End
Begin VB.ComboBox Cbo1
BackColor = &H00FFC0FF&
Height = 300
Left = 1200
TabIndex = 22
Text = "Combo2"
Top = 360
Width = 1485
End
Begin VB.TextBox Txt1
BackColor = &H00FFC0FF&
Height = 345
Left = 1200
TabIndex = 21
Top = 1005
Width = 3195
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "字段名称"
Height = 360
Index = 1
Left = 75
TabIndex = 20
Top = 345
Width = 1305
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "运算符"
Height = 270
Index = 1
Left = 3120
TabIndex = 19
Top = 360
Width = 915
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "关键字"
Height = 240
Index = 1
Left = 60
TabIndex = 18
Top = 1005
Width = 915
End
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 10
Left = 600
Top = 3000
End
Begin VB.CommandButton cmd1
BackColor = &H008080FF&
Caption = ">>"
Height = 375
Left = 5640
Style = 1 'Graphical
TabIndex = 16
Top = 3120
Width = 735
End
Begin VB.OptionButton Option2
BackColor = &H00C0FFC0&
Caption = "日期查询"
Height = 255
Left = 3840
TabIndex = 15
Top = 120
Width = 1095
End
Begin VB.OptionButton Option1
BackColor = &H00C0FFC0&
Caption = "普通查询"
Height = 255
Left = 1080
TabIndex = 14
Top = 120
Value = -1 'True
Width = 1215
End
Begin VB.Frame Frame2
BackColor = &H00FFC0C0&
Enabled = 0 'False
Height = 735
Left = 480
TabIndex = 9
Top = 2040
Width = 5655
Begin MSComCtl2.DTPicker DTPicker2
Height = 255
Left = 3960
TabIndex = 11
Top = 360
Width = 1575
_ExtentX = 2778
_ExtentY = 450
_Version = 393216
CalendarBackColor= 12648384
Format = 61276161
CurrentDate = 39210
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 255
Left = 1080
TabIndex = 10
Top = 360
Width = 1575
_ExtentX = 2778
_ExtentY = 450
_Version = 393216
CalendarBackColor= 12648384
Format = 61276161
CurrentDate = 39210
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "结束日期"
Height = 255
Index = 1
Left = 2955
TabIndex = 13
Top = 360
Width = 855
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "开始日期"
Height = 255
Index = 0
Left = 120
TabIndex = 12
Top = 360
Width = 855
End
End
Begin VB.CommandButton cmdexit
BackColor = &H00C0C0FF&
Cancel = -1 'True
Caption = "返回(&H)"
Height = 405
Left = 3765
Style = 1 'Graphical
TabIndex = 5
Top = 3120
Width = 1080
End
Begin VB.CommandButton cmdfind
BackColor = &H00C0C0FF&
Caption = "查询(&C)"
Default = -1 'True
Height = 405
Left = 1320
Style = 1 'Graphical
TabIndex = 4
Top = 3120
Width = 1080
End
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Height = 1515
Left = 480
TabIndex = 0
Top = 435
Width = 5700
Begin VB.TextBox txtdata
BackColor = &H00FFC0FF&
Height = 345
Left = 1170
TabIndex = 8
Top = 990
Width = 3195
End
Begin VB.ComboBox cboOperator
BackColor = &H00FFC0FF&
Height = 300
Left = 4050
TabIndex = 7
Top = 345
Width = 1485
End
Begin VB.ComboBox cboFields
BackColor = &H00FFC0FF&
Height = 300
Left = 1200
TabIndex = 6
Top = 375
Width = 1485
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "关键字"
Height = 240
Index = 0
Left = 60
TabIndex = 3
Top = 1035
Width = 915
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "运算符"
Height = 270
Index = 0
Left = 3120
TabIndex = 2
Top = 390
Width = 915
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "字段名称"
Height = 360
Index = 0
Left = 75
TabIndex = 1
Top = 375
Width = 1305
End
End
Begin VB.Line Line1
BorderColor = &H000000FF&
BorderWidth = 2
Index = 1
X1 = 120
X2 = 6480
Y1 = 3825
Y2 = 3825
End
Begin VB.Line Line1
BorderWidth = 2
Index = 0
X1 = 105
X2 = 6465
Y1 = 3780
Y2 = 3780
End
End
Attribute VB_Name = "Form17"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim fld
Dim rs As New ADODB.Recordset
Private Sub Cmd1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Call main
rs.Open "select * from " & tb, adoCon, adOpenKeyset, adLockOptimistic
Set fld = rs.Fields
For Each fld In rs.Fields
'向combo控件中添加字段
If fld.Name = "备注" Or fld.Name = "相片" Then
Else
cboFields.AddItem fld.Name
Cbo1.AddItem fld.Name
End If
Next
rs.Close
cboFields.ListIndex = 0: Cbo1.ListIndex = 0
'向cboOperator中添加查询条件
cboOperator.AddItem ("like"): Cbo2.AddItem ("like")
cboOperator.AddItem (">"): Cbo2.AddItem (">")
cboOperator.AddItem ("="): Cbo2.AddItem ("="):
cboOperator.AddItem (">="): Cbo2.AddItem (">="):
cboOperator.AddItem ("<"): Cbo2.AddItem ("<"):
cboOperator.AddItem ("<="): Cbo2.AddItem ("<="):
cboOperator.AddItem ("<>"): Cbo2.AddItem ("<>"):
cboOperator.ListIndex = 0: Cbo2.ListIndex = 0:
Me.Height = 4200
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Frame2.Caption = riqi
If riqi = "" Then
Option2.Enabled = False
End If
End Sub
Private Sub cmdFind_Click() '查询
rs.Open "select * from " & tb, adoCon, adOpenKeyset, adLockOptimistic
If Option1.Value = True Then
If Cbo2.Text = "入库日期" Or cboFields.Text = "入库日期" Or Cbo2.Text = "出库日期" Or Cbo2.Text = "借出日期" Or Cbo2.Text = "归还日期" Or cboFields.Text = "出库日期" Or cboFields.Text = "归还日期" Or cboFields.Text = "借出日期" Or cboFields.Text = "出生日期" Then
If cboOperator.Text = "like" Then
MsgBox "日期型数据不能选用“like”作为运算符!", 48, "提示窗口"
cboOperator.ListIndex = 1
rs.Close
Exit Sub
End If
If IsDate(txtdata) = False Then
MsgBox "请输入正确的日期!", 48, "提示窗口"
rs.Close
Exit Sub
End If
End If
If cboOperator.Text = "like" Then
sql = tb & " where " & tb & "." & cboFields & " like+ '%'+'" + txtdata.Text + "'+'%'"
Else
sql = tb & " where " & tb & "." & cboFields & cboOperator & "'" + txtdata.Text + "'"
End If
Else
If riqi = "" Then
MsgBox "对不起,此窗体不能进行日期查询!", vbInformation + vbOKOnly, "提示"
rs.Close
Exit Sub
Else
sql = tb & " where " & riqi & " Between '" + Str(DTPicker1.Value) + "' AND '" + Str(DTPicker2.Value) + "'"
End If
End If
If cmd1.Caption = "<<" Then
If Cbo2.Text = "like" Then
sql2 = tb & "." & Cbo1 & " like+ '%'+'" + Txt1.Text + "'+'%'"
Else
sql2 = tb & "." & cboFields & Cbo2 & "'" + Txt1.Text + "'"
End If
If Option5.Value = True Then
sql = sql & " and " & sql2
Else
sql = sql & " or " & sql2
End If
End If
sql1 = "select * from " & sql
rs.Close
adoCon.Close
Unload Me
End Sub
Private Sub cmdExit_Click()
adoCon.Close
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
riqi = ""
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then
Frame1.Enabled = True
Frame2.Enabled = False
Else
Frame1.Enabled = True
Frame1.Enabled = False
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
Frame2.Enabled = True
Frame1.Enabled = False
Else
Frame1.Enabled = True
Frame2.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
If cmd1.Caption = ">>" Then
If Me.Height < 7700 Then
Me.Height = Me.Height + 150
Else
Timer1.Enabled = False
cmd1.Caption = "<<"
cmd1.BackColor = RGB(255, 255, 255)
End If
Else
If Me.Height > 4200 Then
Me.Height = Me.Height - 150
Else
Timer1.Enabled = False
cmd1.Caption = ">>"
End If
End If
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -