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

📄 bus.frm

📁 《Visual Basic 6.0趣味程序导学》光盘
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "北京市公交查询系统"
   ClientHeight    =   4830
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5610
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4830
   ScaleWidth      =   5610
   StartUpPosition =   3  'Windows Default
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  'DefaultCursor
      DefaultType     =   2  'UseODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   1560
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "bus"
      Top             =   4320
      Visible         =   0   'False
      Width           =   1140
   End
   Begin VB.CommandButton Command3 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Height          =   375
      Left            =   3240
      TabIndex        =   23
      Top             =   4200
      Width           =   915
   End
   Begin VB.Frame Frame2 
      Height          =   4095
      Left            =   1980
      TabIndex        =   2
      Top             =   660
      Width           =   3435
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   5
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   17
         Top             =   3000
         Width           =   735
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   4
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   16
         Top             =   2520
         Width           =   735
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   3
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   15
         Top             =   2040
         Width           =   735
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   2
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   14
         Top             =   1560
         Width           =   735
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Index           =   5
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   22
         Top             =   3000
         Width           =   2175
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Index           =   4
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   21
         Top             =   2520
         Width           =   2175
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Index           =   3
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   20
         Top             =   2040
         Width           =   2175
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Index           =   2
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   19
         Top             =   1560
         Width           =   2175
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Index           =   1
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   18
         Top             =   1080
         Width           =   2175
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   1
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   13
         Top             =   1080
         Width           =   735
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Index           =   0
         Left            =   1080
         Locked          =   -1  'True
         TabIndex        =   11
         Top             =   600
         Width           =   2175
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   0
         Left            =   120
         Locked          =   -1  'True
         TabIndex        =   10
         Top             =   600
         Width           =   735
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "停靠站"
         Height          =   180
         Left            =   1740
         TabIndex        =   9
         Top             =   240
         Width           =   540
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "车次"
         Height          =   180
         Left            =   360
         TabIndex        =   8
         Top             =   240
         Width           =   360
      End
   End
   Begin VB.Frame Frame1 
      Height          =   4095
      Left            =   120
      TabIndex        =   1
      Top             =   660
      Width           =   1575
      Begin VB.TextBox Text4 
         Height          =   285
         Left            =   240
         TabIndex        =   7
         Top             =   3000
         Width           =   975
      End
      Begin VB.ComboBox Combo1 
         DataSource      =   "Data1"
         Height          =   315
         ItemData        =   "Bus.frx":0000
         Left            =   240
         List            =   "Bus.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   12
         Top             =   720
         Width           =   975
      End
      Begin VB.CommandButton Command2 
         Caption         =   "查询"
         Height          =   375
         Left            =   240
         TabIndex        =   24
         Top             =   3480
         Width           =   735
      End
      Begin VB.TextBox Text3 
         Height          =   270
         Left            =   240
         TabIndex        =   6
         Top             =   2400
         Width           =   975
      End
      Begin VB.CommandButton Command1 
         Caption         =   " 查询"
         Height          =   375
         Left            =   240
         TabIndex        =   4
         Top             =   1200
         Width           =   735
      End
      Begin VB.Label Label7 
         Caption         =   "终点站:"
         Height          =   255
         Left            =   240
         TabIndex        =   26
         Top             =   2760
         Width           =   735
      End
      Begin VB.Label Label6 
         Caption         =   "起点站:"
         Height          =   255
         Left            =   240
         TabIndex        =   25
         Top             =   2160
         Width           =   735
      End
      Begin VB.Line Line1 
         X1              =   60
         X2              =   1500
         Y1              =   1680
         Y2              =   1680
      End
      Begin VB.Label Label3 
         BorderStyle     =   1  'Fixed Single
         Caption         =   " 车站查询"
         Height          =   255
         Left            =   240
         TabIndex        =   5
         Top             =   1800
         Width           =   975
      End
      Begin VB.Label Label2 
         BorderStyle     =   1  'Fixed Single
         Caption         =   " 车次查询"
         Height          =   255
         Left            =   240
         TabIndex        =   3
         Top             =   240
         Width           =   975
      End
   End
   Begin VB.Label Label1 
      BorderStyle     =   1  'Fixed Single
      Caption         =   "          北京市公交查询系统"
      Height          =   255
      Left            =   1140
      TabIndex        =   0
      Top             =   240
      Width           =   3735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dbs As Database, rst As Recordset

Private Sub Command1_Click()
    ClearText
    If Combo1.Text = "" Then
        MsgBox "查询信息不能为空"
    Else
    Data1.Recordset.FindFirst "bus_number = " & Combo1.Text
        Text1(0).Text = Data1.Recordset.Fields("bus_number")
        Text2(0).Text = Data1.Recordset.Fields("bus_station")
    End If
End Sub
Private Sub Command2_Click()
    Dim Station1 As String
    Dim Station2 As String
    Dim i As Integer
    ClearText
    Station1 = Text3.Text
    Station2 = Text4.Text
    If Station1 = "" And Station2 = "" Then
        MsgBox "查询信息不能为空"
    Else
        rst.MoveFirst
        no = 0
        For i = 0 To rst.RecordCount - 1
            If InStr(1, rst.Fields(1), Station1) > 0 And no < 5 And _
            InStr(1, rst.Fields(1), Station2) > 0 Then
                Text1(no).Text = rst.Fields(0)
                Text2(no).Text = rst.Fields(1)
                no = no + 1
            End If
            rst.MoveNext
        Next
        If Text1(0).Text = "" Then
            Text3.Text = ""
            Text4.Text = ""
            MsgBox "没有这样的记录"
        End If
    End If
End Sub

Private Sub Command3_Click()
    End
End Sub

Private Sub Form_Load()
    Data1.DatabaseName = Add(App.Path) + "bus.mdb"
    Data1.RecordSource = "bus"
    
    Set dbs = OpenDatabase(Add(App.Path) + "bus.mdb")
    Set rst = dbs.OpenRecordset("bus")
    For a = 0 To rst.RecordCount - 1
        Combo1.AddItem rst.Fields(0)
        rst.MoveNext
    Next
    If Combo1.ListCount > 0 Then Else Command1.Enabled = False
End Sub

Public Function Add(a As String)
    If Right(a, 1) <> "\" Then Add = a + "\" Else Add = a
End Function

Private Sub Form_Unload(Cancel As Integer)
    rst.Close: dbs.Close
End Sub

Public Sub ClearText()
    For i = 0 To 5
        Text1(i).Text = ""
        Text2(i).Text = ""
    Next
End Sub

⌨️ 快捷键说明

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