Use the pinyin first character sequence in Delphi to implement the search function

zhaozj2021-02-16  91

In daily work and life, we often use electronic notepad to find personal address book information, or query customer profile or business information in units of application. This process often needs to enter a large number of Chinese characters, for familiar computers, this already It is a headache, those users who are not familiar with the computer or if they don't understand Chinese characters, they are afraid. As a new attempt to data retrieval technology, the author explores the first character sequence using Chinese characters as the search keyword, so that users do not have to use Chinese characters, only need to simply type the pinyin preamble of each Chinese character to query information. can. For example, if you want to find the keyword "People's Bank of China", you only need to enter "zgrmyh". The author hopes that by the following examples, the author will make a throwing jade, let us develop more convenient and easy to develop. The principle is very simple, finding the Chinese character in the Chinese character table is "A" to "Z" Chinese characters range, so that the Chinese characters to be retrieved only need to check which one of its first characters, It is possible to judge its pinyin first character. The program is simpler, including 3 controls: a list stores all the information to be retrieved; a list is used to store the search after retrieval; an edit box is used to enter the retrieval keyword (ie, the pinyin first character sequence).

The details are as follows: 1. Enter Delphi to create a new project: Project1 2. Create the following controls on Form1 and fill in the properties: Control type Property Name Property Value Edit Name SearchListBox Name SourceEListItems Enter some strings, such as name, etc., used to provide retrieval data Listbox Name Resultlist3. Type two functions // Get the phrase of the phrase of Chinese characters, such as: "Han" index letter is "H" function getpyindexchar (hzchar: string): char; begin case word (hzchar [1]) SHL 8 Word (Hzchar [2]) of $ B0A1 .. $ B0C4: Result: = 'A'; $ B0C5 .. $ B2C0: Result: = 'b'; $ b2c1 .. $ b4ed: result: = 'c'; $ B6E9: $ B6E9: = 'D'; $ B6EA .. $ B7A1: Result: = 'E'; $ B7A2. $ B8C0: Result: = 'f'; $ b8c1 .. $ b9fd: result: RESULT: = 'G'; $ bbf6: Result: = 'h'; $ bbf7 .. $ bfa5: result: = 'J'; $ bfa6 .. $ c0ab: result: = 'k'; $ C0AC. $ C2E7: RESULT: = 'L'; $ C2E8 .. $ C4C2: Result: = 'm'; $ C4C3 .. $ C5B5: Result: = 'N'; $ C5B6 .. $ c5bd: Result: = ' O '; $ C5BE .. $ C6D9: Result: =' P '; $ C6DA .. $ C8BA: Result: =' Q '; $ C8BB .. $ C8F5: Result: =' R '; $ C8F6 .. CBF9: RESULT: = 's'; $ CBFA .. $ CDD9: Result: = 't'; $ CDDA .. $ CEF3: Result: = 'W'; $ CEF4 .. $ D188: Result: = 'x' $ D1b9 .. $ d4d0: result: = 'y'; $ d4d1 .. $ d7f9: result: = 'z'; else result: = char (0); end; end; // list in the specified string SourceSTRS Retrieves all strings that match the pinyin index string pyindexstr and return.

转载请注明原文地址:https://www.9cbs.com/read-12194.html

New Post(0)