问题如上...就是单个单词.还请赐教....多谢!!!!

解决方案 »

  1.   

    你用下面的函数试试:  分割字符串    
        
    typeTResultArray = array of string;function SplitString(const source, ch: string): TResultArray;vartemp: string;i: integer;begintemp := source;i := pos(ch, source);while i <> 0 dobeginSetLength(Result, Length(Result) + 1);Result[Length(Result) - 1] := copy(temp, 0, i - 1);delete(temp, 1, i);i := pos(ch, temp);end;SetLength(Result, Length(Result) + 1);Result[Length(Result)-1] := Temp;end;**************function SplitString(const source,ch:string):tstringlist;vartemp:string;i:integer;beginresult:=tstringlist.Create;temp:=source;i:=pos(ch,source);while i<>0 dobeginresult.Add(copy(temp,0,i-1));delete(temp,1,i);i:=pos(ch,temp);end;result.Add(temp);end;调用MEMO1中的某行,用空格来分割,你就可以得到单词了:
    for j := 0 to memo1.line.count -1
    begin
    s:=splitstring(memo1.Lines.Strings[i],' ');for i:=0 to s.Count-1 dob:=b+s.Strings[i]+#13;showmessage(b);
    end;
    s.free;
     
       
      

  2.   

    ?不是吧
    上面的代码没有看懂?
    反正上面有一个函数splitstring(memo1.Lines.Strings[i],' ');大概就是取出
    MEMO1中的一行,然后以空格为界限,把里面所有的单词分割出来就是了。。
      

  3.   

    "问一个很菜的问题:如何获取memo中的单个字符串,我只能得到整行字符串."有了整行字符串就好办了呀。
    copy(s, startcharpos, count);这个函数返回整行字符串s中从起始字符位置startchar向后数count个字符的字符串。
    pos(substring, s);这个函数返回子字符串substring在总字符串s中的位置。所以假设s为'Let us study Delphi!'
    copy(s, pos('D', s), 6);将返回'Delphi'明白这个原理后,你再看Drate(小虫)给你的代码,就应改能看懂了吧。