Attention tout de même avec StringGrid1.cells[k-1,j][1] car si la chaine est vide, cela provoque une belle erreur de violation d'accès !
---

Nono du Moulin

---
-------------------------------
Réponse au message :
-------------------------------
Salut .
Le type Char, a une largeur de un octet.
tu tentes un transtypage incorrecte
s:= IntToStr(char(StringGrid1.cells[k-1,j])) ;
La propriété Cells de la stringµGrid, est une liste
de chaines du type String donc une classe. S ne
peut pas contenir la représentation Char de
plusieurs éléments (String).
Mais tu peux récupérer pour 1 élément de la chaine.
Exemple :
s:= IntToStr(char(StringGrid1.cells[k-1,j][1])) ;
ou pour écrir plus lisiblement :
s:= StringGrid1.cells[k-1,j][1] ;//Récupère le 1°
//caratère de la chaine
s:= IntToStr(char(s));
StringGrid1.Cells[k,j]:=IntToStr(Ord(s[1]));
A +.
http://philippe.gormand.free.fr
-------------------------------
Réponse au message :
-------------------------------
Salut a tous,
en executant ce code la fonction Ord ne marche pâs sur le contenu du stringgrid :
----------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
i, j, k : integer;
s : Char;
begin
for j:=1 to stringgrid1.rowcount-1 do
begin
for k:=0 to StringGrid1.ColCount-1 do
begin
if not ((k+j) mod 2 = 0) then
StringGrid1.Cells[k,j]:=Char(k+j)
else
begin
s:= IntToStr(char(StringGrid1.cells[k-1,j])) ;
StringGrid1.Cells[k,j]:=IntToStr(Ord(s));
end;
end;
end;
end;
----------------
un petit test pour resoudre ce prob !
Meric [:-)]