procedure TfrmMG_Edit.DBComboBox4Click(Sender: TObject);
var
  sqlStr:string;
begin    //列出所有客户
 if dbcombobox4.ItemIndex>=0 then
 begin
  sqlStr:='select * from SubBase where TP='+stringlist1.strings[DBcombobox4.itemindex];
  adoquery1.SQL.Clear;
  adoquery1.SQL.Text:=sqlStr;
  adoquery1.Open;
  stringlist2.Clear;
  DBcombobox3.Clear;
  while not adoquery1.Eof do
  begin
    DBcombobox3.Items.Append(trim(adoquery1.fieldbyname('Title').AsString));
    stringlist2.add(adoquery1.fieldbyname('ID').asstring);
    adoquery1.Next;
  end;
  if trim(kf.Caption)<>'' then
    dbcombobox3.ItemIndex:=dbcombobox3.Items.IndexOf(trim(kf.Caption)); end;为什么这段我在Winxp 里面没问题,在98里却提示非法操作,关闭程序?

解决方案 »

  1.   

    是的。98下面(可能是某些版本的98),StringList不允许空元素。也就是说,里面的string不能为空。
      

  2.   

    ID: 18872, TComboBox patch for Delphi 7 (QC #2246) 
    by Petr Vones Email: AnonymousThe patch fixes bug in TCustomComboBoxStrings.Get method causing an Access Violation for empty string item in Delphi 7.  
    Download Details 
    Download  3.2K 
    To download this, you must have registered:  Your existing free membership 
     For Delphi, Version 7.0 to 7.0 2225 downloads 
    Copyright: No significant restrictions 
    Updated on Sun, 26 Oct 2003 10:37:03 GMT 
    Originally uploaded on Tue, 24 Sep 2002 13:33:31 GMT  
       Explore the files in this upload
    Show line numbers  1 
    File Name Date/Time Size 
    PatchDemo.res  10/26/2003 7:26:00 PM 876 bytes 
    PatchDemo.dpr  9/24/2002 10:14:16 PM 279 bytes 
    D7ComboBoxStringsGetPatch.pas  10/26/2003 7:26:36 PM 2.8K 
    PatchDemoMain.pas  9/24/2002 10:24:42 PM 383 bytes 
    PatchDemoMain.dfm  10/26/2003 7:35:40 PM 1.6K 
    1 File Exploration is Disabled
    We're sorry, but errors in the uploaded zip file prevent it from being explored.The error generated by the Zip attachment is:You may still be able to repair the zip file contents if you download the entire zip locally. You may also want to ask the author to repost the attachment.
     
    Description  
    Problem: Selecting an empty string in TComboBox component will cause Access Violation on some systems. See details in Quality Central report #2246.Description: On some systems (Windows 2000 SP3) it will cause Access Violation in ntdll.dll for an empty string item.The patch fixes it for both standalone executables or applications compiled with runtime packages. To use it just add D7ComboBoxStringsGetPatch.pas unit to the project.Updated for using with Debug DCUs. Thanks to Pavel Rogulin.  
    以上是我在网上http://cc.codegear.com/Item.aspx?id=18872找的资料
    说是要加入一个.pas文件就可以
    是怎么加入呢?文件我已经有了。
      

  3.   

    这个跟你的问题没有任何关系。在Win98下有一个内存限制(具体忘了),即便是使用Windows自带的Notepad.exe,也不能象现在的Win2k/XP/2k3那样,打开超大文件。
      

  4.   

    当然对于Delphi7,必须要打足相应的补丁(好象是SP1).