大家帮我看看,奇了怪s.报错。。。。[Pascal Error] Unit1.pas(1): Unable to invoke Code Completion

  • 主题发起人 主题发起人 楚辞
  • 开始时间 开始时间

楚辞

Unregistered / Unconfirmed
GUEST, unregistred user!
大家帮我看看,奇了怪s.报错。。。。[Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in(10)<br />我想实现如下字符串: s1="169.254.92.1" s2="www.csdn.net" s3="9999" 然后把s1,s2,s3,和在一起,中间用|隔开。:“169.254.92.1|www.csdn.net|9999|“ 现刚走第一步:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; procedure Button1Click(Sender: TObject); private procedure MyString(TempStr:String;Number:Integer); { Private declarations } public { Public declarations } end; var Form1: TForm1; s:array of string; implementation uses Unit2; {$R *.dfm} procedure Form1.MyString(TempStr:String;Number:Integer); begin s. end;[Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source code
 
楼主想说什么阿?s.当然错误阿,你没有输入完整的代码阿。
 
E文说,你的代码有错误
 
我想说明的是:输入控件的后面自动出现想要选择的东西,比如OpenDialog1.Execute(这个可以出来)而我的 s.后面则没有出来。我不是已经申明了的嘛!s:array of string; 我疑惑的就在这里。
 
LZ还是补习一下基础吧,这种问题实在让人......
 
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private procedure MyString(TempStr:String;Number:Integer); { Private declarations } public { Public declarations } end;var Form1: TForm1; s:array of string;implementation uses unit2;{$R *.dfm}procedure TForm1.MyString(TempStr: String; Number: Integer); var s:array of String;begin s.SetLength(Number); for i:=0 to Number-1 do begin s:=Copy(TempStr,1,Pos('|',TempStr)-1); TempStr:=Copy(TempStr,Pos('|',TempStr)+1,Length(TempStr)-Pos('|',TempStr)); end;end;procedure TForm1.Button1Click(Sender: TObject);var s1,s2,s3,s4,s5:string; begin s1:=edit1.text; s2:=edit2.Text; s3:=edit3.Text; edit4.Text:=s1+'|'+s2+'|'+s3; s4:=edit4.Text; //s5:=MyString( s4,1); &Otilde;&acirc;&Ecirc;&Ccedil;&cedil;&ouml;&sup1;&yacute;&sup3;&Igrave;&pound;&not;&Atilde;&raquo;&Oacute;&ETH;·&micro;&raquo;&Oslash;&Ouml;&micro;&micro;&Auml; //&sup2;&raquo;&Auml;&Uuml;&Otilde;&acirc;&Ntilde;ù&micro;÷&Oacute;&Atilde; //&Ouml;±&frac12;&Oacute;MyString(s4,1); &frac34;&Iacute;&ETH;&ETH;&Aacute;&Euml;&iexcl;&pound; mystring( s4,1); edit1.Text:=s5; end;所有报错。。。。。大家给看看,到底错在哪了?[Error] Unit1.pas(38): Record, object or class type required[Error] Unit1.pas(38): Incompatible types[Error] Unit1.pas(39): Undeclared identifier: 'i'
 
楼上说的不错啊。俺也纳闷,这个程序是从书上得来得了,可是书上却没有说它有误。所以然我也解决不了。。。。
 
procedure TForm1.FormCreate(Sender: TObject);vars1,s2,s3,s4 :string;begins1:='169.254.92.1'; s2:='www.csdn.net' ; s3:='9999' ; s4 := '169.254.92.1|www.csdn.net|9999|'; s4 := s1 +'|'+ s2 +'|'+ s3;end;end.
 
procedure TForm1.Button1Click(Sender: TObject);vars1,s2,s3,s4 :string;begins1:=edit1.Text; s2:=edit2.Text ; s3:=edit3.Text ; s4 := '169.254.92.1|www.csdn.net|9999|'; s4 := s1 +'|'+ s2 +'|'+ s3; showmessage(s4);end;
 
还是报错。[Error] Unit1.pas(38): Record, object or class type required[Error] Unit1.pas(38): Incompatible types[Error] Unit1.pas(39): Undeclared identifier: 'i'
 
加了个i:integer;提示错误少了。就剩下了两句:。[Error] Unit1.pas(38): Record, object or class type required s.SetLength(Number);(错误在S。后面)[Error] Unit1.pas(38): Incompatible types s.SetLength(Number);
 
s.SetLength(s,1);这个修改了下,[Error] Unit1.pas(40): Record, object or class type required
 
s.SetLength(Number); 改成 SetLength(s, Number);
 
果真编译过去。太谢谢大家了!
 
总算是编译过去了。谢谢大家了。
 
后退
顶部