DELPHI里面有没有类似VB中的ISNULL()函数,比如测试一个字符变量是否为空的函数

解决方案 »

  1.   

    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.
      

  2.   

    楼上的大哥,我E文不怎么好呀,是声明一个property IsNull: Boolean;就可以用isnull()了吗?
      

  3.   

    楼主查查Delphi的帮助就明白了
      

  4.   

    例:
      if  ADOTable1.FieldByName('a').IsNull then
          begin
            showmessage('不能空');
            exit;
          end;
      ADOTable1.Post;
    与VB的可能不相同,
    delphi里好像没有直接判断某个字符串变量是否为空的函数,不过,你用其他方法可以做到,
    如setLenght()
      

  5.   

    if Assigned(v) then
    begin
      //do something
    end;参阅borland帮助中关于Assigned函数的解释或者  可以直接判断 
    if obj = nil then
    beginend;喜欢用哪种方法 完全看个人爱好
      

  6.   

    当然 上述方法是针对 指针相关类型的
    比如
    var f: TForm;
    .....
    if Assigned(f) then ... 或者
    if f = nil then ....
    如果是字符的话可以这样判断
    var
      c: Char;
    ...
    if c = '' then ...
      

  7.   

    var 
    MyStr:String;
    MyPchar:Pchar;
    begin
    if MyStr='' then ……
    if MyPchar=nil then ……
    end;