比如用文本框输入数据到数据库,如何检查输入的数据类型是否匹配,delphi 里有自带函数判断数据类型么?比如判断输入是否为数字!是否是时间类型!
请教了!!
请教了!!
解决方案 »
- property 中read 和 write问题
- 发个帖子看看我的结贴率是多少,呵
- 小数点的问题
- 问一个弱的,Delphi如何打包、如何更换.exe文件的图标啊?
- 强烈询问 delphi 7的TSeverSocket和TClientSocket组见哪里去了?
- 如何解决图形丢失的问题?
- 哪位在delphi中用MapX4.5开发过软件,帮我解决一个速度问题
- 如何把SQL数据库表里面的一个字段所有记录存到本机的一个文本文件里?
- 如何通过代码设置LISTVIEW控件的标题头的宽度?
- GetAsyncKeyState 一直困扰我的问题!
- 关于.hlp帮助文件的指定关键字的调用问题。求助
- 在adoconnect.sql.text中 访问access数据库 查询一段时间?
if key not in ('0','1','2','3','4'等等) then key=#0
就可以了
function IsIntStr(str: string): boolean;
begin
try
StrToInt(str);
result:=true;
Except
result:=false;
end;
end;function IsDateStr(str): boolean;
begin
TempFormat:=ShortDateFormat; //保存操作系统的日期格式
ShortDateFormat:='yyyy-mm-dd';//把系统日期格式改成你使用的日期格式
try
StrToDate(str);
result:=true;
except
result:=false;
end;
ShortDateFormat:=TempFormat;//恢复原来的系统日期格式
end;
var Key: Char);
begin
case key of
'0','1','2','3','4','5','6','7','8','9',#8:key:=key;
else
key:=#0;
end;
end;
procedure TdataRelationPub.allFloatOnKeypress(Sender: TObject;
var Key: Char);
begin
case key of
'0','1','2','3','4','5','6','7','8','9',#8:key:=key;
'.':begin
if pos('.',TCustomEdit(Sender).Text)<>0 then
key:=#0;
end
else
key:=#0;
end;
end;
begin
if (CurField.DataType in [ftFloat,ftCurrency,ftBCD]) then
begin
if not((key in ['0'..'9','.','-',#8])) then
begin
key := #0
end
else
begin
if (Key='.') and (Pos('.',TEdit(Sender).Text)<>0) then
Key:=#0
else if
(Key='-') and (Pos('-',TEdit(Sender).Text)<>0) then
Key:=#0;
end;
end
else if (CurField.DataType in [ftAutoInc,ftSmallint, ftInteger, ftWord,
ftBytes,ftLargeint]) then
begin
if not ((Key in ['0'..'9','-',#8])) then
begin
Key:=#0
end
else
begin
if(Key='-') and (Pos('-',TEdit(Sender).Text)<>0) then
Key:=#0;
end;
end
else
Exit;
end;CurField是字段类型。
里面写!