转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
DELPHI常用函数集及简要范例         ★★★★

DELPHI常用函数集及简要范例

作者:闵涛 文章来源:闵涛的学习笔记 点击数:19881 更新时间:2009/4/23 18:30:33
;{SelLength = 0}
     TmpStr := Copy(Text,1,SelStart-1)+Copy(Text,SelStart+1,255)
    else {Key in [''''A''''..''''Z'''', etc]}
     TmpStr := Copy(Text,1,SelStart)+Key+Copy(Text,SelLength+SelStart+1,255);
    if TmpStr = '''' then Exit;
    { update SelSt to the current insertion point }

    if (Key = Chr(vk_Back)) and (SelSt > 0) then Dec(SelSt)

    else if Key <> Chr(vk_Back) then Inc(SelSt);
    Key := #0; { indicate that key was handled }
    if SelSt = 0 then 
    begin
      Text:= '''';
      Exit;
    end;

   {Now that TmpStr is the currently typed string, see if we can locate a match }

    Found := False;
    for i := 1 to Items.Count do
      if Copy(Items[i-1],1,Length(TmpStr)) = TmpStr then
      begin
        Text := Items[i-1]; { update to the match that was found }
        ItemIndex := i-1;
        Found := True;
        Break;
      end;
    if Found then { select the untyped end of the string }
    begin
      SelStart := SelSt;
      SelLength := Length(Text)-SelSt;

    end
    else Beep;
  end;
end;
##  Copy, Chr, SelStart, SelLength example
-----------------------------------------------------------------------------
High    传回注脚的最大值.
-----------------------------------------------------------------------------
Unit  System
函数原型 function High(X);
范例  [Ordinal type]
   procedure TForm1.Button1Click(Sender: TObject);
   var
     Low_S:String;
     High_S:string;
     S:String;
   begin
     High_S:=''''  High=''''+IntToStr(High(Word));
     Low_S:=''''Low=''''+IntToStr(Low(Word));
     S:=Low_S+High_S;
     Label1.Caption:=S;
   end;

   S:=Low=0  High=65535

   [Array type]
   procedure TForm1.Button1Click(Sender: TObject);
   var
     P : Array[5..21] of Double;
     Low_S:String;
     High_S:string;
     S:String;
   begin
     High_S:=''''  High=''''+IntToStr(High(P));
     Low_S:=''''Low=''''+IntToStr(Low(P));
     S:=Low_S+High_S;
     Label1.Caption:=S;
   end;

   S:=Low=5  High=21

   [String type]
   procedure TForm1.Button1Click(Sender: TObject);
   var
     P : String[23];
     Low_S:String;
     High_S:string;
     S:String;
   begin
     High_S:=''''  High=''''+IntToStr(High(P));
     Low_S:=''''Low=''''+IntToStr(Low(P));
     S:=Low_S+High_S;
     Label1.Caption:=S;
   end;

   S:=Low=0  Hight=23

   P:ShortString;
   S:=Low=0  Hight=255

   P:String;
   长字串不可,会有错误讯号.

   [Open array]
   function Sum( var X: array of Double): Double;
   var
     I: Word;
     S: Double;
   begin
     S := 0;
     { Note that open array index range is always zero-based. }
     for I := 0 to High(X) do S := S + X[I];
    Sum := S;
   end;
Example
function Sum( var X: array of Double): Double;

var
  I: Word;
  S: Real;
begin
  S := 0; { Note that open array index range is always zero-based. }
  for I := 0 to High(X) do S := S + X[I];
  Sum := S;
end;

procedure TForm1.Button1Click(Sender: TObject);

var
  List1: array[0..3] of Double;
  List2: array[5..17] of Double;
  X: Word;
  S, TempStr: string;
begin
  for X := Low(List1) to High(List1) do
      List1[X] := X * 3.4;
  for X := Low(List2) to High(List2) do
      List2[X] := X * 0.0123;
  Str(Sum(List1):4:2, S);
  S := ''''Sum of List1: '''' + S + #13#10;
  S := S + ''''Sum of List2: '''';
  Str(Sum(List2):4:2, TempStr);

  S := S + TempStr;
  MessageDlg(S, mtInformation, [mbOk], 0);
end;
##  Low, High Example
-----------------------------------------------------------------------------
Low    传回注脚的最小值.
-----------------------------------------------------------------------------
Unit  System
函数原型 function Low(X);
说明  Ordinal type  The lowest value in the range of the type
   Array type  The lowest value within the range of the 
       index type of the array
   String type  Returns 0
   Open array  Returns 0
   String parameter Returns 0
-----------------------------------------------------------------------------
Ord    传回列举型态的数值.
-----------------------------------------------------------------------------
Unit  System
函数原型 function Ord(X): Longint;
范例  procedure TForm1.Button1Click(Sender: TObject);
   type
     Colors = (RED,BLUE,GREEN);
   var
     S: string;
   begin
     S := ''''BLUE has an ordinal value of '''' + IntToStr(Ord(RED)) + 
    #13#10;
     S := S+''''The ASCII code for "c" is '''' + IntToStr(Ord(''''c'''')) +  '''' 
    decimal'''';
     MessageDlg(S, mtInformation, [mbOk], 0);
   end;
-----------------------------------------------------------------------------
Round    将实数转为整数.(有四舍五入)
-----------------------------------------------------------------------------
Unit  System
函数原型 function Round(X: Extended): Longint;
范例  var
     S, T: string;
   begin
     Str(1.4:2:1, T);
     S := T + '''' rounds to '''' + IntToStr(Round(1.4)) + #13#10;
     Str(1.5:2:1, T);
     S := S + T + '''' rounds to '''' + IntToStr(Round(1.5)) + #13#10;

 << 上一页  [21] [22] [23] [24] [25] [26] [27] [28] [29] [30]  ...  下一页 >> 


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台