shell13010
Messages postés73Date d'inscriptionmardi 3 avril 2007StatutMembreDernière intervention12 mai 2013
-
6 avril 2009 à 16:13
f0xi
Messages postés4205Date d'inscriptionsamedi 16 octobre 2004StatutModérateurDernière intervention12 mars 2022
-
7 avril 2009 à 03:51
Bonjour a tous,
je me trouve fasse a un probleme que j'arrive pas a resoudre
j'ai un listbox et je voudrais que quand une personne click sur une
items me renvoie le string en decimal voici mon code qui renvoie la
premiere items mais j'arrive pas a renvoyer nimporte quel item
procedure TForm4.ListBox1Click(Sender: TObject);
var S:string;
I:integer;
Conv:string;
begin
S:=ListBox1.Items.Strings[0]; //va me renvoyer l'items 0 //ici et mon probleme
for i:=1 to length(s) do Conv:=Conv+inttostr(ord(s[i]))+',';
edit2.text:=(Conv); //me renvoie le mot en decimal
showmessage(Choix(ListBox1));
end;
comment je pourrais enlever le 0 pour que l'item 2 ou 3 etc... peut etre convertie?
cs_cantador
Messages postés4720Date d'inscriptiondimanche 26 février 2006StatutModérateurDernière intervention31 juillet 202113 6 avril 2009 à 17:03
bonjour,
function RenvoiDec: string;
var
S: string;
i, j: integer;
Conv: string;
begin
with Form1 do
for i := 0 to ListBox1.Items.Count - 1 do
if ListBox1.Selected[i] then
begin
S := ListBox1.Items.Strings[i];
for j := 1 to length(S) do
Conv := Conv + IntToStr(ord(S[j])) + ',';
Result := Conv;
end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
Edit1.Text := RenvoiDec;
end;
shell13010
Messages postés73Date d'inscriptionmardi 3 avril 2007StatutMembreDernière intervention12 mai 20131 6 avril 2009 à 17:17
bon voila se que j'ai fait pour se a qui sa intéresserer plutard, mais je pense pas que se soit la methode douce mais sa marche donc si vous avez une autre idée je suis preneur...
procedure TForm4.ListBox1Click(Sender: TObject);
var S:string;
I:integer;
a:integer;
Conv:string;
begin
for I := 0 to ListBox1.Items.Count - 1 do
if ListBox1.Selected[I] then
S:= ListBox1.Items.Strings[i];
for a:=1 to length(s) do Conv:=Conv+inttostr(ord(s[a]))+',';
edit2.text:=(Conv);
showmessage(choix(listbox1));
end;
procedure TForm1.FormCreate(Sender: TObject);
var A : char;
B : byte absolute A;
begin
for A := #0 to #255 do
CharToCode[A] := IntToStr(B);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var S,E : string;
I,L : integer;
begin
S := ListBox1.Items[ListBox1.itemindex];
E := '';
L := Length(S);
for I := 1 to L do
if I < L then
E := E + CharToCode[S[I]] + ', '
else
E := E + CharToCode[S[I]];
L_art_ment
Messages postés302Date d'inscriptionvendredi 21 septembre 2007StatutMembreDernière intervention 6 février 2013 6 avril 2009 à 16:57
Ah si ok j'ai compris ce que tu entends par "le string en decimal", bein dans l'evenement OnClick de ta ListBox si tu mets :
S:=ListBox1.Items[ListBox1.ItemIndex];
s sera égal à l'item selectionné (si selection il y a).