摘要: 首部 function Format(const Format: string; const Args: array of const): string; $[SysUtils.pas 功能 返回按指定方式格式化一个数组常量的字符形式 说明 这个函数是我在Delphi中用得最多的函数,现在就列举几个例子给你个直观的理解 "% " [索引 ": "] [ "- "] [宽度] [ ". " 摘要] 类型 Format( 'x=%d ', [12]); // 'x=12 ' //最普通 阅读全文
posted @ 2011-03-02 16:33 吴越 阅读(437) 评论(0) 推荐(0) 编辑
摘要: 根据haochin的回复,我稍微改了一下,最后是这样:use Clipbrdprocedure TForm1.Button2Click(Sender: TObject);var I : Integer;begin Clipboard.Clear; for I := 0 to ListBox1.Count - 1 do begin Clipboard.AsText := Clipboard.AsText +listbox1.Items[I]+#13#10; end; //Clipboard.SetTextBuf(PChar(listbox1.Items.Text));end;可作为详细参考的内容 阅读全文
posted @ 2011-03-02 14:30 吴越 阅读(465) 评论(0) 推荐(0) 编辑
摘要: //绝对值: Absvar d: Real; v: Variant;begin d := Abs(-1.2); ShowMessage(FloatToStr(d)); {1.2} v := '-100'; ShowMessage(v); {-100; v 是变体类型无需转换} v := Abs(v); ShowMessage(v); {100; 如果变量的确是个数字, 变体类型也是可以取绝对值}end;//返回整数: Trunc、Round、Intvar i: Integer; d: Real;begin i := Trunc(1234.5678); {截断} ShowMess 阅读全文
posted @ 2011-03-02 10:08 吴越 阅读(167) 评论(0) 推荐(0) 编辑
摘要: //返回整数的四种情况const a = 1.8; b = -1.8;begin {返回比值大的最小整数:} ShowMessage(IntToStr(Ceil(1.8)) + ',' + IntToStr(Ceil(-1.8))); {返回:2,-1} {返回比值小的最大整数:} ShowMessage(IntToStr(Floor(1.8)) + ',' + IntToStr(Floor(-1.8))); {返回:1,-2} {删除小数部分:} ShowMessage(IntToStr(Trunc(1.8)) + ',' + IntToStr 阅读全文
posted @ 2011-03-02 10:07 吴越 阅读(215) 评论(0) 推荐(0) 编辑
摘要: //整除与余数: DivModconst a = 11; b = 3;var x,y: Word;begin ShowMessage(IntToStr(a div b)); {整除得 3} ShowMessage(IntToStr(a mod b)); {余数 2} DivMod(a,b,x,y); ShowMessage(IntToStr(x)); {3} ShowMessage(IntToStr(y)); {2}end;//返回整数: Ceil、Floorvar d1,d2: Real;const d = 1.2;begin {向大补入} d1 := Ceil(d); d2 := Ceil 阅读全文
posted @ 2011-03-02 10:06 吴越 阅读(349) 评论(0) 推荐(0) 编辑