procedure TForm1.Button1Click(Sender: TObject);
var
strColor: string;
i, R, G, B, p: integer;
strlist: TStringList;
begin
strColor := medt.Text + '-';
strlist := TStringList.Create;
try
for R := 0 to 2 do //把變量R改為i正常
begin
//showmessage(inttostr(r)); 加上這句也正常了 循環體內讀過R 值
p := pos('-', strColor);
strlist.Add(copy(strColor, 0, p-1));
delete(strColor, 1, p);
end;
R := strToint(strlist[0]);
G := strToint(strlist[1]);
B := strToint(strlist[2]);
finally
strlist.Free;
end;
Self.Color := TColor (RGB (R, G, B));
edtColor.Text := '$' + IntToHex (TColor (RGB (R, G, B)), 8);
edtColor.SetFocus;
end;