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

📄 buschange.frm

📁 换乘的vb代码 很有用哦 大家快看看吧
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Begin VB.Form BusSelect 
   Caption         =   "Form1"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton BusCmd1 
      Caption         =   "确定"
      Height          =   495
      Left            =   1680
      TabIndex        =   4
      Top             =   2400
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1680
      TabIndex        =   1
      Text            =   "Text2"
      Top             =   1560
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1680
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label Label2 
      Caption         =   "终点:"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   1680
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "起点:"
      Height          =   255
      Left            =   240
      TabIndex        =   2
      Top             =   840
      Width           =   615
   End
End
Attribute VB_Name = "BusSelect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub buschang() '公交线路换乘
    Dim BusfirstName() As Variant
    Dim BuslastName() As Variant
    Dim m, t As Integer
    Dim through As Boolean       '判断是否直接到达
    Dim exist As Boolean         '判断是否可以公交线路换乘
    BusSelect.BusList1.Clear
    Call connetion
    If BusSelect.BusOption4.Value = True Then
    
        '先确定有哪些公交车经过站点
        '=========================================================================================================
        cmd.CommandText = "select * from SiteName where SiteName like ? order by BusNameID ASC"
        
        '设置para相关属性
        para.Type = adBSTR
        para.Direction = adParamInput
        para.Value = BusSelect.BusTxt1.Text

        '把para添加到参数集
        cmd.Parameters.Append para
        cmd.Parameters(0) = BusSelect.BusTxt1.Text

        '执行command对象
        Set rs = cmd.Execute
        If Not rs.EOF Then
            n = rs.RecordCount
            ReDim BusfirstName(n)
            For i = 0 To n - 1
                BusfirstName(i) = rs("BusName").Value
                rs.MoveNext
            Next
            rs.Close
        '=========================================================================================================

        '然后对每一俩公交车进行排除
        '=========================================================================================================
            For i = 0 To n - 1
                Call connetion
                cmd.CommandText = "select * from SiteName where BusName=? order by BusNameID ASC"
        
                '设置para相关属性
                para.Type = adBSTR
                para.Direction = adParamInput
                para.Value = BusfirstName(i)

                '把para添加到参数集
                cmd.Parameters.Append para
                cmd.Parameters(0) = BusfirstName(i)

                '执行command对象
                Set rs = cmd.Execute
                through = True
                Do While Not rs.EOF
                    If rs("SiteName").Value = Trim(BusSelect.BusTxt2.Text) Then       '直接到达
                        BusSelect.BusList1.AddItem "您可以直接乘坐第" & BusfirstName(i) & "公交车"
                        Exit Sub
                    Else                                                              '无直接到达
                        through = False
                    End If
                    rs.MoveNext
                Loop
                rs.Close
        '======================================================================================================

        '无直接到达
        '======================================================================================================
                If through = False Then
                    '=============================================================================================
                    Call connetion
                    cmd.CommandText = "select * from SiteName where BusName=? order by BusNameID ASC"
                    '设置para相关属性
                    para.Type = adBSTR
                    para.Direction = adParamInput
                    para.Value = BusfirstName(i)

                    '把para添加到参数集
                    cmd.Parameters.Append para
                    cmd.Parameters(0) = BusfirstName(i)

                    '执行command对象
                    Set rs = cmd.Execute
                    If Not rs.EOF Then
                        t = rs.RecordCount
                        ReDim bussite(t)
                        For p = 0 To t - 1
                            bussite(p) = rs("SiteName").Value
                            rs.MoveNext
                        Next
                        rs.Close
                    End If
                    For l = 0 To t
                        Call connetion
                        cmd.CommandText = "select * from SiteName where SiteName=? order by BusNameID ASC"
                        '设置para相关属性
                        para.Type = adBSTR
                        para.Direction = adParamInput
                        para.Value = Trim(BusSelect.BusTxt2.Text)

                        '把para添加到参数集
                        cmd.Parameters.Append para
                        cmd.Parameters(0) = Trim(BusSelect.BusTxt2.Text)

                        '执行command对象
                        Set rs = cmd.Execute
                        If Not rs.EOF Then
                            m = rs.RecordCount
                            ReDim BuslastName(m)
                            For j = 0 To m - 1
                                BuslastName(j) = rs("BusName").Value
                                rs.MoveNext
                            Next
                            rs.Close
                            For k = 0 To m - 1
                                Call connetion
                                cmd.CommandText = "select * from SiteName where BusName=? order by BusNameID ASC"
                                '设置para相关属性
                                para.Type = adBSTR
                                para.Direction = adParamInput
                                para.Value = BuslastName(k)

                                '把para添加到参数集
                                cmd.Parameters.Append para
                                cmd.Parameters(0) = BuslastName(k)

                                '执行command对象

⌨️ 快捷键说明

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