Delphi practical programming experience 2

Source: Internet
Author: User


Delphi is a new visual programming environment, providing us with a convenient and quick windows application development tool.
The following are two practical experiences in Delphi programming, which we hope to share with you:
1. Use hypertext link Markup Language (HTML). Access HTML files using open methods (such as IE) in Windows is too large and not flexible. Delphi provides the thtml control, which can call HTML files, but does not detail how to call the HTML files of the Local Machine in its attributes. In fact, this function can be completed as long as the correct URL format is used. The format is as follows:
File: hosts & lt; host & gt;/& lt; Path & gt;
For example, if the path of an HTML file is C:/help/homehtm, the correct URL format is file: export C:/help/homehtm. Therefore, the HTML file called by the html1 control should be: html1requestdoc (File: Using C:/help/homehtm ). In this way, you can write a program to call HTML files to form an independent help file system.
2. fuzzy query of field data using SQL. As an important symbol of a powerful database application development tool, Delphi supports SQL programming. In the actual process, fuzzy queries are often required for certain fields. For example, if the "name" field is queried, all records of the surname Wang can be automatically listed when "Wang" is entered. In fact, this function can be easily completed by combining the features of SQL and Delphi. The basic principle is: When querying, the query range is controlled between the name greater than 'query string + CHR (0) 'and the smaller than 'query string + CHR ($ ff, you can query all records that meet the conditions. The following is an example:
VaR
Namestr: string; delimiter: Set the variable in the string.
Begin
Namestr: = 'wang ′;
Query1sqlclear {clear SQL command statements in SQL properties}
Query1sqladd ('select * fromcustomdbwhere (name1 & gt; = N1) and (name2 & lt; = n2) '); explain SQL command statement
Query1params [0] asstring: = namestr + CHR (0); callback Control Parameter in namestr + CHR (0)
Query1params [1] asstring: = namestr + CHR ($ ff); Between bytes and namestr + CHR ($ ff)
Query1open; then open the database and execute SQL queries
End;(Yang Bo, Shaanxi)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.