The results showed as:
Beijing south Texas east of jinan Shanghai...
Beijing south
East Texas
Jinan
Shanghai
CodePudding user response:
That's easy,First of all, get a list of two station after the train, then, to find the two standing there are trains,
Assume that your information is stored in the database, the code using the three ListBox, they can be set to invisible,
'in the list box the same string API
Private Declare Function SendMessagebyString Lib _
"User32" Alias "SendMessageA" (ByVal hWND As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long As String)
Private Const LB_FINDSTRINGEXACT=& amp; H1A2 'precise search in the ListBox
Obtain all stops
'Set the rs=cn. The Execute (" SELECT DISTINCT stop_name FROM your_table ORDER BY stop_name ")
List1. Clear
EOF
Do Until the rs.List1 AddItem rs! Stop_name
Rs. MoveNext
Loop
'iterate through all the stations for
For I=0 To List1. ListCount - 2
The train 'access to the station
Set the rs=cn. Execute (" SELECT train_number FROM your_table WHERE stop_name='" & amp; List1. List (I) & amp; "'")
List2. Clear
EOF
Do Until the rs.List2 AddItem rs! Train_number
Rs. MoveNext
Loop
For j=I + 1 To List1 ListCount - 1
'he stood for train
Set the rs=cn. Execute (" SELECT train_number FROM your_table WHERE stop_name='" & amp; List1. List (j) & amp; "'")
List3. Clear
EOF
Do Until the rs.If SendMessagebyString (List2 hWnd LB_FINDSTRINGEXACT, 1, rs! Train_number) & gt; 1 Then List3 AddItem rs! Train_number
Rs. MoveNext
Loop
The Debug. Print List1. List (I) & amp; "& lt; - & gt;" & List1. List (j)
If List3. ListCount=0 Then
The Debug. Print "no through train"
The Else
For k=0 To List3. ListCount - 1
The Debug. Print List3. List (k)
Next k
End the If
Next j
Next I
CodePudding user response:
That the connection to the database, could you tell me how to connect? Output the result?CodePudding user response:
This was done, but do is bus, as the principle,Your table structure to be in the same way as I was,
Since the connection query table,
CodePudding user response:
QQ: 5507350