📄 form1.frm
字号:
VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5460
ClientLeft = 60
ClientTop = 345
ClientWidth = 8085
LinkTopic = "Form1"
ScaleHeight = 5460
ScaleWidth = 8085
StartUpPosition = 3 '窗口缺省
Begin MSComctlLib.TreeView TreeView1
Height = 2415
Left = 0
TabIndex = 10
Top = 2160
Width = 8055
_ExtentX = 14208
_ExtentY = 4260
_Version = 393217
Style = 7
Appearance = 1
End
Begin VB.CommandButton Command5
Caption = "寻路"
Height = 375
Left = 1560
TabIndex = 9
Top = 5040
Width = 1335
End
Begin VB.CommandButton Command4
Caption = "列出经过道路"
Height = 375
Left = 120
TabIndex = 6
Top = 5040
Width = 1335
End
Begin VB.TextBox Text3
Height = 270
Left = 2880
TabIndex = 5
Top = 4680
Width = 1575
End
Begin VB.CommandButton Command3
Caption = "列出相邻城市"
Height = 255
Left = 6720
TabIndex = 4
Top = 4680
Width = 1335
End
Begin VB.TextBox Text2
Height = 270
Left = 600
TabIndex = 3
Top = 4680
Width = 1695
End
Begin VB.TextBox Text1
Height = 2055
Left = 0
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 0
Width = 8055
End
Begin VB.CommandButton Command1
Caption = "split data"
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 2655
End
Begin InetCtlsObjects.Inet Inet1
Left = 3000
Top = 0
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
Protocol = 4
URL = "http://"
End
Begin VB.CommandButton Command2
Caption = "split data"
Height = 375
Left = 3720
TabIndex = 2
Top = 120
Width = 3855
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "to"
Height = 180
Left = 2520
TabIndex = 8
Top = 4725
Width = 180
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "from"
Height = 180
Left = 120
TabIndex = 7
Top = 4725
Width = 360
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim dbrs As New ADODB.Recordset
Dim allway() As String
Dim n&
Private Sub Command1_Click()
allway = Split(Text1.Text, "----------------")
MsgBox "split data as " & UBound(allway)
End Sub
Private Sub Command2_Click()
Dim dbr As New ADODB.Recordset
Dim waylinedata() As String
Dim ways As Long
Dim waydata() As String
Dim points() As String
Dim cpoint() As String
Dim wayname As String
Dim wayid As Long
Dim ncity&
Dim pcity&
Dim nd&
Dim pd&
dbr.Open "select * from waypoints", conn, 1, 3
For i = 0 To UBound(allway)
waydata = Split(allway(i), "城市名{|}与下站距离{|}距起点距离{|}所属省份")
points = Split(waydata(1), Chr(13))
ways = UBound(points) - 2
ReDim waylinedata(ways, 3)
Me.Caption = waydata(0)
wayname = Trim(waydata(0))
wayname = Replace(wayname, Chr(13), "")
wayname = Replace(wayname, Chr(10), "")
wayid = add_way(wayname)
Text2.Text = Text2.Text & waydata(0) & Chr(13) & "has " & UBound(points) & " records" & Chr(13)
For j = 1 To UBound(points) - 1
cpoint = Split(points(j), "{|}")
Text2.Text = Text2.Text & Chr(9) & UBound(cpoint) & Chr(13)
waylinedata(j - 1, 0) = add_city(Trim(cpoint(0)), add_province(Trim(cpoint(3))))
waylinedata(j - 1, 1) = cpoint(1)
waylinedata(j - 1, 2) = cpoint(2)
waylinedata(j - 1, 3) = add_province(Trim(cpoint(3)))
Me.Caption = waydata(0) & cpoint(0)
' For m = 0 To 3
' Text2.Text = Text2.Text & waylinedata(j - 1, m) & Chr(9)
' Next
DoEvents
Next
For m = LBound(waylinedata) To UBound(waylinedata)
If m = LBound(waylinedata) Then
pcity = -1
pd = 0
Else
pcity = waylinedata(m - 1, 0)
pd = waylinedata(m - 1, 1)
End If
If m = UBound(waylinedata) Then
ncity = -1
nd = 0
Else
ncity = waylinedata(m + 1, 0)
nd = waylinedata(m, 1)
End If
dbr.AddNew
dbr("way_id") = wayid
dbr("city_id") = waylinedata(m, 0)
dbr("ncity_id") = ncity
dbr("pcity_id") = pcity
dbr("ndistance") = nd
dbr("pdistance") = pd
dbr.Update
Debug.Print waylinedata(m, 0), waylinedata(m, 1), waylinedata(m, 2), waylinedata(m, 3)
Next
Next
MsgBox "done"
End Sub
Private Sub Command3_Click()
Dim dbr As New ADODB.Recordset
dbr.Open "select * from citys where city like '%%" & Text2.Text & "%%'", conn, 1, 1
Text1.Text = ""
Do While Not dbr.EOF
Text1.Text = Text1.Text & "---------------------------" & Chr(13) & Chr(10)
Text1.Text = Text1.Text & dbr("city") & Chr(13) & Chr(10)
Text1.Text = Text1.Text & showncity(dbr("city_id")) & Chr(13) & Chr(10)
DoEvents
dbr.MoveNext
Loop
dbr.Close
End Sub
Private Sub Command4_Click()
Dim dbr As New ADODB.Recordset
Text1.Text = ""
dbr.Open "select top 1 * from citys where city like '%%" & Text2.Text & "%%'", conn, 3, 3
Text1.Text = Text1.Text & "起始城市:" & Text2.Text & Chr(13) & Chr(10)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -