listbox上的数据每次取10条连成一个串,不足10条时也组成一个串,放到另一个listbox上
如:
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
a11
a12在另一个listbox上:
a1a2a3a4a5a6a7a8a9a10
a11a12
如:
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
a11
a12在另一个listbox上:
a1a2a3a4a5a6a7a8a9a10
a11a12
解决方案 »
- 保留小数问题。
- 我在DLL中建立了一个TImage,但调用时出现错误"Cannot assign a TFont to a TFont"
- 动态生成的按钮触发问题,请大家帮忙看看
- 如何实现 CSDN 上树的功能~~~~~ 相关树~~~~100分路过也帮忙顶一下~~谢谢~~~~~~
- 宏调用--调用另一FORM上的控件,使其动作(在线等)
- 帮帮忙,怎样用IWTreeView控件读取后台数据啊
- 读卡器的应用 ??急用??
- 如何在设计一类型文件时,设计一个字符串长度大于255
- 请问TListView 中用到的图片 能否使用 LoadFromFile的方法?
- 哪儿有MP3《--》WAV的控件?好一点的。
- 这里为什么要用个类呢?一个初学者的问答!
- 怎么获得该控件的句柄?
i,j:integer;
str:string;
begin
for i:=1 to (listbox1.Items.Count div 10 )+1 do
begin
str:='';
for j:=(i-1)*10 to (i*10-1) do
begin
if j<listbox1.Items.Count then
str:= str+listbox1.Items[j];
end;
listbox2.Items.Add(str); end;
end;
var i:integer;
begin
for i:=0 to 35 do
listbox1.Items.Add('a'+inttostr(i));
end;procedure TForm1.Button1Click(Sender: TObject);
var a:string;
i:integer;
begin
for i:=1 to 30 do
if i mod 10<>0 then
begin
a:=a+listbox1.Items[i];
end
else if i mod 10=0 then
begin
listbox2.Items.Add(a);
a:='';
end;
end;
j:=0;
while j<ListBox1.Items.Count do
begin
vStr:='';
for i:=0 to 9 do
begin
if j=ListBox1.Items.Count then 不足10个退出
Break;
vStr:=vStr+ListBox1.Items[j];
Inc(j);
end;
ListBox2.Items.Add(vStr);
end;
COM1COM2COM3COM4COM7COM9假如上面是listbox上的一项,请问怎么获得该字符串有几个'COM'字符?
函数应返回6
怎么写
function GetStrCount(vSource,vKey:String):Integer;
var
vCount:integer;
vTmpSource:String;
begin
vTmpSource:=vSource;
vCount:=0;
while Pos(vKey,vTmpSource)<>0 do
begin
vTmpSource:=Copy(vTmpSource,Pos(vKey,vTmpSource)+1,Length(vTmpSource));
Inc(vCount);
end;
Result:=vCount;
end;
function GetStrCount(vSource,vKey:String):Integer;
var
vCount:integer; //最后结果
vTmpSource:TStrings;
vTmpString:String;
begin
vTmpSource:=TStringList.Create;
vTmpString:=vSource; //做个备份
vTmpSource.Text:=StringReplace(vTmpString,vKey,#13#10,[rfReplaceAll, rfIgnoreCase]);
//这里是关键,把关键字改成回车放到TStrings里,TSTrings的个数就是关键字的个数.
Result:=vTmpSource.Count;
end;