ListM
13899990000
13588880000
13322321234
.
ListA
1389999 in A
District 1351111 B
1332232 C
.
This two lists, I will from listM listA regions are obtained, how cycle,
CodePudding user response:
Must be traversal listM entries, each a listM project, such as 13899990000, go to the second list from the beginning to the end to find a match,CodePudding user response:
ListA sorting first, write a function to use the binary search method,As long as the listM layer cycle, cycle within call lookup function,
CodePudding user response:
The Like operator
Used to compare two strings,
Syntax
Result=string Like the pattern
Like the grammar of the operator has the following several parts:
Part of the description
Result is required; Any numerical variables,
String required; Any string expression,
The pattern required; Any string expression, follow the "instructions" in the pattern matching convention,
Description
If the string matching with the pattern, the result is True. If don't match, the result is False, but if a Null string, or the pattern, the result is Null,
The characteristics of the Like operator as Option Compare different statements, each module Option is the default string comparison method of Compare Binary,
In string comparison, Option Compare the results of the Binary is derived according to the internal Binary representation of the characters the sort order, in Microsoft Windows, the sort order is determined by the code page, the case usually Binary sort order:
A. & lt; B & lt; E & lt; Z & lt; a
Option in string comparison Compare the results of the Text is the comparison of the string, it is based on Text case-insensitive sort order, based on which a sort order is determined by system of our country, the use of the same characters Option Compare Text will produce the following Text sort order:
(A=A) & lt; (_=_) & lt; (B)=B & lt; (E)=E & lt; (_=_) & lt; (Z=Z) & lt;=(_ _)
Built-in pattern matching function provides a variety of tools to compare strings, with pattern matching function can use a wildcard, string list matching strings, or any combination of characters interval to allow the characters in the following form is pointed out that the pattern and how they relate to what match:
The pattern of the characters in line with the string
? Any single character,
* zero or more characters,
# any number (0-9),
[charlist] charlist. Any single character,
[! Charlist] any single character, not in the charlist
In brackets ([]), can be used by one or more characters (charlist) group and any character in the string matching, this group include almost any one character code and number,
Attention to and left parenthesis ([), a question mark (?), digital symbol (#) and the asterisk (*), and other special characters match, they can be in square brackets, and cannot be used within a set of right parenthesis () and its matching, but outside the group can be used as individual characters,
Through on the range, with A hyphen (-) between the lower limit, the charlist can specify the scope of the characters, for example, if the location of the corresponding character in the string including A - Z between any capital letters, then [a-z] get A match, don't need A delimiter, square brackets can include multiple range,
The meaning of the specified range depends on the effective character sorting runtime (as Option Compare and setting up the system of our country, as determined in the code in the run), use Option Compare Binary sample as you can see, the range [A] - E and A, B and E, matching by Option Compare the Text as you can see, [A] - E and A, A, _, _, B, B, E, E, matching this range with _ _ or don't match, because according to the sort order, accented characters after the accented characters,
This is a list of other important pattern matching rules:
Charlist at the beginning of exclamation mark (!) Means that if you find any character that does not belong to charlist in string, there is a match, if use exclamation point outside the brackets, the exclamation mark with their match,
A hyphen (-) can appear in the beginning of the charlist (if use exclamation point, after the exclamation mark), also can appear at the end of the charlist match with oneself, in any other places, even the characters used to identify the scope of the characters,
When specify the scope of characters, these characters must be in ascending order, from smallest to largest) in order to show that [a-z] is an effective pattern, but not [Z - A],
Character sequence [] is seen as a zero-length string (" "),
Some language has some special characters in the alphabet, they represent two separate characters, for example, in some languages, when the character "a" and "e" appears at the same time, indicated by the symbol "_" character "a" and "e", and the Like operator can recognize a single special characters and two individual characters are equal,
When a language is to use a special character, and the characters in the system has been set for a specified time, appear in the pattern or a string of a single special characters will be with other matching equivalence of the two characters in a string, similarly, enclosed by square brackets in the pattern of single special characters (character itself in a list or range) with matching equivalence of the two characters in a string sequence,
CodePudding user response:
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
Private Sub Command1_Click ()
Dim As Long, I n the As Long
For I=0 To ListM. ListCount - 1
N=SendMessagebyString (ListA hWnd LB_FINDSTRINGEXACT, 1, Left (ListM. List (I), 7))
If n & gt; 1 Then the Debug. Print ListM. List (I), ListA. List (n)
Next I
End Sub