⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 find.frm

📁 进销存管理系统是基于用户的数据库管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmFind 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "查找"
   ClientHeight    =   2190
   ClientLeft      =   1995
   ClientTop       =   2595
   ClientWidth     =   5025
   HelpContextID   =   2016128
   Icon            =   "FIND.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1824.622
   ScaleMode       =   0  'User
   ScaleWidth      =   4945.396
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.ListBox lstFields 
      Height          =   1680
      Left            =   240
      TabIndex        =   7
      Top             =   360
      Width           =   1455
   End
   Begin VB.ComboBox cboOperators 
      Height          =   300
      Left            =   2040
      Style           =   2  'Dropdown List
      TabIndex        =   6
      Top             =   360
      Width           =   975
   End
   Begin VB.TextBox txtExpression 
      Height          =   285
      Left            =   3360
      TabIndex        =   0
      Top             =   360
      Width           =   1455
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确定(&O)"
      Default         =   -1  'True
      Enabled         =   0   'False
      Height          =   375
      Left            =   2040
      MaskColor       =   &H00000000&
      TabIndex        =   1
      Top             =   1200
      Width           =   1215
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取消(&C)"
      Height          =   375
      Left            =   3480
      MaskColor       =   &H00000000&
      TabIndex        =   2
      Top             =   1200
      Width           =   1215
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "运算符:"
      Height          =   180
      Index           =   1
      Left            =   2040
      TabIndex        =   4
      Top             =   120
      Width           =   720
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "字段:"
      Height          =   180
      Index           =   0
      Left            =   240
      TabIndex        =   3
      Top             =   120
      Width           =   540
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "值或表达式:"
      Height          =   180
      Index           =   2
      Left            =   3360
      TabIndex        =   5
      Top             =   120
      Width           =   1080
   End
End
Attribute VB_Name = "frmFind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'该变量用以表示查询窗体所生成的SQL语句
Public msResultSQL As String

Private Sub cmdCancel_Click()
    msResultSQL = ""
    
    Me.Hide
End Sub

Private Sub txtExpression_Change()
  cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(cboOperators.Text) > 0 And Len(txtExpression.Text) > 0
End Sub

Private Sub lstFields_Click()
  cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(cboOperators.Text) > 0 And Len(txtExpression.Text) > 0
End Sub

Private Sub cboOperators_Click()
  cmdOK.Enabled = Len(lstFields.Text) > 0 And Len(cboOperators.Text) > 0 And Len(txtExpression.Text) > 0
End Sub

Private Sub Form_Load()
   '加载查询所需要使用的运算符号
   cboOperators.AddItem "="
   cboOperators.AddItem "<>"
   cboOperators.AddItem ">="
   cboOperators.AddItem "<="
   cboOperators.AddItem ">"
   cboOperators.AddItem "<"
   cboOperators.AddItem "Like"
   cboOperators.ListIndex = 0
        
   msResultSQL = ""
End Sub

Private Sub cmdOK_Click()
    '改变指针,告知当前处于忙的状态
    Screen.MousePointer = vbHourglass
    
    '取得查询所需要的字段、符号和值
    Dim sField As String
    Dim sExpr As String
    Dim sOperator As String
    sField = lstFields.Text
    sExpr = txtExpression.Text
    sOperator = cboOperators.Text
    
    Dim sTemp As String
    If LCase(sOperator) = "like" Then
        sTemp = sField & " " & sOperator & " '%" & sExpr & "%'"
    Else
        sTemp = sField & " " & sOperator & " '" & sExpr & "'"
    End If
    '返回查询所得的结果
    msResultSQL = sTemp
    
    Me.Hide
    
    '恢复指针,告知系统已经不忙了
    Screen.MousePointer = vbDefault
End Sub

'只写的属性SQL
Public Property Let SQL(ByVal vNewValue As Variant)
    On Error GoTo errHandler

    Dim strSQL  As String
    strSQL = CStr(vNewValue)
    
    '通过传递进来的SQL语句,取得表的各个字段的结构
    Dim rs As New ADODB.Recordset
    rs.Open strSQL, gConn, adOpenKeyset, adLockReadOnly
    
    '将字段填入到字段列表中
    Dim fld
    For Each fld In rs.Fields
        lstFields.AddItem fld.Name
    Next fld
    
    rs.Close
    
    Exit Property
    
errHandler:
    MsgBox Err.Description, vbCritical, "错误"
End Property

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -