我是菜鸟,刚接触DELPHI,我做了一个小窗体,但一运行时,就会出现错误提示,"发生未知错误",然后代码就指向了, if not IsCircular and这行,,这是怎么回事啊?我非常迷糊现在,不知道是哪里出了问题,请大家帮看看啊,

解决方案 »

  1.   

    关机重起,如果还不行,建议重新安装delphi
      

  2.   

    if not IsCircular and这行 你是怎样写的?包括前后的代码!
      

  3.   

    begin
        if FLookupDisplayAssigned then
          Result := FLookupDisplayText
        else
        begin
          S := ListFieldName;
          if S = '' then S := KeyFieldName;
          if S <> '' then
          begin
            Pos := 1;
            S := ExtractFieldName(S, Pos);
    就停到下面这了,,,
            if not IsCircular and
              (VarEquals(ListSource.DataSet.FieldByName(KeyFieldName).Value, ALookupKeyValue) or
               ListSource.DataSet.Locate(KeyFieldName, ALookupKeyValue, [])) then
                FLookupDisplayText := ListSource.DataSet.FieldByName(S).DisplayText
            else
              FLookupDisplayText := '';
          end;
          FLookupDisplayAssigned := True;
        end;
      end还有,我的小窗体的名字叫MYDEL,可是一运行时却转到了dxDBEdit这个文件的代码上来了,上面的代码就是dxDBEdit中的,
    是怎么回事啊,大家帮分析分析,
      

  4.   

    if not IsCircular and
              (VarEquals(ListSource.DataSet.FieldByName(KeyFieldName).Value, ALookupKeyValue) or
               ListSource.DataSet.Locate(KeyFieldName, ALookupKeyValue, [])) then
                FLookupDisplayText := ListSource.DataSet.FieldByName(S).DisplayText
            else
              FLookupDisplayText := '';
          end;
    ================================================
    把这句话拆开执行,包括条件里面的东西,用showmessage隔断,看看哪块报错。
      

  5.   

    感谢LS,但是"用showmessage隔断,"这个项到底在哪啊,我怎么找不到啊,
      

  6.   

    showmessage指的显示一个对话框,这个作用是让程序执行到这里以后停止。以便减少你代码的出错范围。
      

  7.   

    if (not IsCircular) and   //加括号
              (VarEquals(ListSource.DataSet.FieldByName(KeyFieldName).Value, ALookupKeyValue) or
               ListSource.DataSet.Locate(KeyFieldName, ALookupKeyValue, [])) then
      

  8.   

    if not IsCircular 
    {and   
              (VarEquals(ListSource.DataSet.FieldByName(KeyFieldName).Value, ALookupKeyValue) or
               ListSource.DataSet.Locate(KeyFieldName, ALookupKeyValue, [])) } then
    看看这样行不行,如果行的话就是你另外两个条件有问题了!
      

  9.   

    代码看起来费劲,定义几个临时Boolean变量,先赋值再进行布尔运算啊!