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

📄 form4.frm

📁 房产信息管理系统 VB+ACCESS 值得借鉴
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form4 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "查找房产信息"
   ClientHeight    =   2940
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6300
   Icon            =   "Form4.frx":0000
   LinkTopic       =   "Form4"
   MaxButton       =   0   'False
   ScaleHeight     =   2940
   ScaleWidth      =   6300
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command1 
      Caption         =   "查找"
      Height          =   375
      Left            =   1200
      TabIndex        =   4
      Top             =   2190
      Width           =   1455
   End
   Begin VB.Frame Frame1 
      Height          =   1575
      Left            =   503
      TabIndex        =   6
      Top             =   360
      Width           =   5295
      Begin VB.OptionButton Option2 
         Caption         =   "按销售价格"
         Height          =   255
         Left            =   720
         TabIndex        =   1
         Top             =   960
         Width           =   1215
      End
      Begin VB.OptionButton Option1 
         Caption         =   "按房产户型"
         Height          =   255
         Left            =   720
         TabIndex        =   0
         Top             =   360
         Value           =   -1  'True
         Width           =   1215
      End
      Begin VB.TextBox Text2 
         Enabled         =   0   'False
         Height          =   270
         Left            =   2760
         TabIndex        =   3
         Top             =   960
         Width           =   1695
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Left            =   2760
         TabIndex        =   2
         Top             =   360
         Width           =   1695
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   375
      Left            =   3480
      TabIndex        =   5
      Top             =   2190
      Width           =   1455
   End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Sub Command1_Click()
On Error GoTo error
Check
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Public Sub FindHouse1()
On Error GoTo error
Dim rs As New ADODB.Recordset
Dim sql As String
Dim li As ListItem
'查找操作
sql = "SELECT * FROM House WHERE Kind='" & Text1.Text & "'"
rs.Open sql, conn, adOpenStatic, adLockReadOnly
'查找结果为空
If rs.RecordCount = 0 Then
rs.Close
MsgBox "没有相应信息!", vbInformation
Exit Sub
End If
'查找结果显示
Do Until rs.EOF = True
Set li = Form1.ListView1.ListItems.Add(, , rs.Fields("ID"), 6, 1)
li.SubItems(1) = rs.Fields("Kind")
li.SubItems(2) = rs.Fields("Address")
li.SubItems(3) = rs.Fields("Price")
li.SubItems(4) = rs.Fields("Area")
rs.MoveNext
Loop
rs.Close
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Public Sub FindHouse2()
On Error GoTo error
Dim rs As New ADODB.Recordset
Dim sql As String
Dim li As ListItem
'查找操作
sql = "SELECT * FROM House WHERE Price=" & Text2.Text & ""
rs.Open sql, conn, adOpenStatic, adLockReadOnly
'查找结果为空
If rs.RecordCount = 0 Then
rs.Close
MsgBox "没有相应信息!", vbInformation
Exit Sub
End If
'查找结果显示
Do Until rs.EOF = True
Set li = Form1.ListView1.ListItems.Add(, , rs.Fields("ID"), 6, 1)
li.SubItems(1) = rs.Fields("Kind")
li.SubItems(2) = rs.Fields("Address")
li.SubItems(3) = rs.Fields("Price")
li.SubItems(4) = rs.Fields("Area")
rs.MoveNext
Loop
rs.Close
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Public Sub Check()
On Error GoTo error
If Option1.Value = True Then
If Trim(Text1.Text) = "" Then
MsgBox "房产户型为空!", vbExclamation
Text1.SetFocus
Exit Sub
End If
Form1.ListView1.ListItems.Clear
FindHouse1
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "销售价格为空!", vbExclamation
Text2.SetFocus
Exit Sub
End If
If IsNumeric(Text2.Text) = False Then
MsgBox "销售价格不是数字!", vbExclamation
Text2.SetFocus
Exit Sub
End If
Form1.ListView1.ListItems.Clear
FindHouse2
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Command2_Click()
On Error GoTo error
Unload Me
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Form_Load()
On Error GoTo error
Dim rtn As Boolean
Form(4) = True
rtn = SetWindowPos(hwnd, -1, 0, 0, 0, 0, 3)
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error GoTo error
Form(4) = False
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Option1_GotFocus()
On Error GoTo error
Text1.Enabled = True
Text2.Enabled = False
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Option2_GotFocus()
On Error GoTo error
Text1.Enabled = False
Text2.Enabled = True
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Text1_GotFocus()
On Error GoTo error
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
On Error GoTo error
If KeyAscii = vbKeyReturn Then
Command1.SetFocus
Command1_Click
End If
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Text2_GotFocus()
On Error GoTo error
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
On Error GoTo error
If KeyAscii = vbKeyReturn Then
Command1.SetFocus
Command1_Click
End If
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub

⌨️ 快捷键说明

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