[RESUELTO] Delimiter y DelimitedText [ListBox]
#1
Posted 11 January 2011 - 09:46 AM
Saludos
#2
Posted 11 January 2011 - 10:01 AM
No se si exista una función que haga eso, pero hay muchas opciones para hacerlo, esta es mi propuesta
delphi
function ContarLetras(cadena:string;caracter:char):integer; var lineas: TStringList; begin lineas := TStringList.Create; Lineas.StrictDelimiter := true; Lineas.Delimiter := Caracter; Lineas.DelimitedText := cadena; result := Lineas.Count-1; lineas.Free; end; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(inttostr(ContarLetras('Returns the index value of a substring.','e'))); end;
Salud OS
#3
Posted 11 January 2011 - 10:08 AM
Salduos.
#4
Posted 11 January 2011 - 10:16 AM
No se si exista una función que haga eso, pero hay muchas opciones para hacerlo, esta es mi propuesta
delphi
function ContarLetras(cadena:string;caracter:char):integer; var lineas: TStringList; begin lineas := TStringList.Create; Lineas.StrictDelimiter := true; Lineas.Delimiter := Caracter; Lineas.DelimitedText := cadena; result := Lineas.Count-1; lineas.Free; end; procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(inttostr(ContarLetras('Returns the index value of a substring.','e'))); end;
Salud OS
Ah si, cuando quise matar moscas a cañonazos
Salud OS
#5
Posted 11 January 2011 - 10:17 AM
#6
Posted 11 January 2011 - 10:38 AM
#7
Posted 11 January 2011 - 11:07 AM
Básicamente la idea es:
1) En la propiedad Delimiter colocar el carácter delimitador.
2) En la propiedad DelimiterText el texto a partir.
3) Listo... ya tienes en la propiedad Strings la cadena partida.
Saludos,
#8
Posted 11 January 2011 - 11:17 AM
#9
Posted 11 January 2011 - 11:25 AM
Eso acabo de confirmar amigo Delphius en D7 no existe esa propiedad y así mismo como lo comentas no me funciona desde el ListBox, tendré que pasarlo antes por un Stringlist antes de intoriducirlo al Listbox, ya comento los resultados.
Pos... si que está raro , porque a mi me funciona:
procedure TForm1.bnPartirClick(Sender: TObject); const Text = 'hola$Fernando$esto$debería$funcionar'; begin lbxListado.Items.Delimiter := '$'; //delimitador lbxListado.Items.DelimitedText := Text; // el texto a partir end;
En el ListBox lbxListado aparece el texto partido:
hola
Fernando
esto
debería
funcionar
Saludos,
#10
Posted 11 January 2011 - 11:29 AM
Saludos.
#11
Posted 11 January 2011 - 11:34 AM
No tienes que agradecérmelo. Hoy por ti, mañana por mi.gracias por aclararmelo amigo Delphius.
Saludos.
Además, mejor ni te digo los intentos que hice hace tiempo para aprender a usar estas dos propiedades. Me inventé cada rueda
Saludos,
#12
Posted 11 January 2011 - 12:16 PM
Saludos