delphi语法.txt20如果你努力去发现美好,美好会发现你;如果你努力去尊重他人,你也会获得别人尊重;如果你努力去帮助他人,你也会得到他人的帮助。生命就像一种回音,你送出什么它就送回什么,你播种什么就收获什么,你给予什么就得到什么。if 表达式 then
begin
语句一;
end
else if 表达式二 then
begin
语句二;
.......
end
else
begin
语句n;
end;
if MessageDlg('Welcome to my
Delphi application. Exit now?',
mtConfirmation, [mbYes, mbNo,mbok], 0) = mrYes then
begin
语句
end
end;
end.
判断文件是否存在
if FileExists('C:\Windows\RegEdit.Exe') =true/false then
ShowMessage('regedit.exe文件存在!');
opendialog运行,判断打开文件的位置
if OpenDialog1.Execute then
begin
showmessage(OpenDialog1.FileName);
end;
删除文件
try
deletefile('文件路径和文件名');
except
showmessage('error');
end;
直接删的话,就用上面这段代码,已经考虑到了如果当文件不存在时的情况
FormatDateTime用法
声明为:
function FormatDateTime(const Format: string; DateTime: TDateTime): string;
overload;
返回值是一种格式化后的字符串,重点来看Format参数中的指令字符
c 以短时间格式显示时间,即全部是数字的表示
FormatdateTime('c',now);
输出为:2004-8-7 9:55:40
d 对应于时间中的日期,日期是一位则显示一位,两位则显示两位
FormatdateTime('d',now);
输出可能为1~31
dd 和d的意义一样,但它始终是以两位来显示的
FormatdateTime('dd',now);
输出可能为01~31
ddd 显示的是星期几
FormatdateTime('ddd',now);
输出为: 星期六
dddd 和ddd显示的是一样的。但上面两个如果在其他国家可能不一样。ddddd 以短时间格式显示年月日
FormatdateTime('ddddd',now);
输出为:2004-8-7
dddddd 以长时间格式显示年月日
FormatdateTime('dddddd',now);
输出为:2004年8月7日
e/ee/eee/eeee 以相应的位数显示年
FormatdateTime('ee',now);
输出为:04 (表示04年)
m/mm/mmm/mmmm 表示月
FormatdateTime('m',now);
输出为:8
FormatdateTime('mm',now);
输出为 08
FormatdateTime('mmm',now);
输出为 八月
FormatdateTime('mmmm',now);
输出为 八月
和ddd/dddd 一样,在其他国家可能不同yy/yyyy 表示年
FormatdateTime('yy',now);
输出为 04
FormatdateTime('yyyy',now);
输出为 2004,
h/hh,n/nn,s/ss,z/zzz 分别表示小时,分,秒,毫秒
t 以短时间格式显示时间
FormatdateTime('t',now);
输出为 10:17
tt 以长时间格式显示时间
FormatdateTime('tt',now);
输出为10:18:46
ampm 以长时间格式显示上午还是下午
FormatdateTime('ttampm',now);
输出为:10:22:57上午
大概如此,如果要在Format中加普通的字符串,可以用双引号隔
开那些特定义的字符,这样普通字符串中如果含特殊的字符就不会被显示为时间格式啦:
FormatdateTime('"today is" c',now);
输出为:today is 2004-8-7 10:26:58
时间中也可以加"-"或"\"来分开日期:
FormatdateTime('"today is" yy-mm-dd',now);
FormatdateTime('"today is" yy\mm\dd',now);
输出为: today is 04-08-07
也可以用":"来分开时间
FormatdateTime('"today is" hh:nn:ss',now);
输出为:today is 10:32:23
insertrecord 和appendrecord用法
table1.insertrecord([edt1.text,edt2.text,.......]),DB文件用多少个选项,就可以用多少个edt.text来编辑,也可以,直接在里面写你要写的文本。
如: table1.insertrecord(['韩国','汉城','......'])
Appendrecord用法 同上。