Indicates whether the value assigned to the parameter is NULL (blank).Delphi syntax:property IsNull: Boolean;C++ syntax:__property bool IsNull = {read=FNull, nodefault};DescriptionInspect IsNull to discover if the value of the parameter is NULL, indicating the value of a blank field. NULL values can arise in the following ways:Assigning the value of another, NULL, parameter. Assigning the value of a blank field. Calling the Clear method.Note: NULL parameters are not the same as unbound parameters. Unbound parameters have not had a value assigned. NULL parameters have a NULL value. NULL parameters may be bound or unbound.
例: if ADOTable1.FieldByName('a').IsNull then begin showmessage('不能空'); exit; end; ADOTable1.Post; 与VB的可能不相同, delphi里好像没有直接判断某个字符串变量是否为空的函数,不过,你用其他方法可以做到, 如setLenght()
if Assigned(v) then begin //do something end;参阅borland帮助中关于Assigned函数的解释或者 可以直接判断 if obj = nil then beginend;喜欢用哪种方法 完全看个人爱好
当然 上述方法是针对 指针相关类型的 比如 var f: TForm; ..... if Assigned(f) then ... 或者 if f = nil then .... 如果是字符的话可以这样判断 var c: Char; ... if c = '' then ...
var MyStr:String; MyPchar:Pchar; begin if MyStr='' then …… if MyPchar=nil then …… end;
Assigning the value of a blank field.
Calling the Clear method.Note: NULL parameters are not the same as unbound parameters. Unbound parameters have not had a value assigned. NULL parameters have a NULL value. NULL parameters may be bound or unbound.
if ADOTable1.FieldByName('a').IsNull then
begin
showmessage('不能空');
exit;
end;
ADOTable1.Post;
与VB的可能不相同,
delphi里好像没有直接判断某个字符串变量是否为空的函数,不过,你用其他方法可以做到,
如setLenght()
begin
//do something
end;参阅borland帮助中关于Assigned函数的解释或者 可以直接判断
if obj = nil then
beginend;喜欢用哪种方法 完全看个人爱好
比如
var f: TForm;
.....
if Assigned(f) then ... 或者
if f = nil then ....
如果是字符的话可以这样判断
var
c: Char;
...
if c = '' then ...
MyStr:String;
MyPchar:Pchar;
begin
if MyStr='' then ……
if MyPchar=nil then ……
end;