Delphi code block: PADL and padr

Source: Internet
Author: User

Release commonly used code blocks. Similarly, it is only suitable for beginners. It is estimated that there are already a lot of code blocks in the hands of veterans.

During application, we often need to fill in spaces or 0 before or after a string, which is similar to the PADL and padr functions in oralce, such as completing two places in the acquired month, the obtained ticket number is supplemented with 11 digits (the first digit is supplemented with 0. so I implemented these two small functions myself.

// Copyright (c) hydonlee. For details, enter the original address // Add to the left, EX: PADL ('20170', 5, '0 ') = & gt; 00123 function PADL (asource: string; alimit: integer; apadchar: Char = ''): string; var I: integer; begin result: = asource; for I: = 1 to alimit-length (result) Do begin result: = apadchar + result; end; // copyright (c) hydonlee, ex: padr ('20170', 5, '0') => 123 function padr (asource: string; alimit: integer; apadchar: Char = ''): string; vaR I: integer; begin result: = asource; for I: = 1 to alimit-length (result) Do begin result: = Result + apadchar; end;

 

Copyright (c) hydonlee

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.