Te recomiendo no abusar tanto del operador
as. Si como te indicó el amigo
Neftali compruebas que Sender es un TPanel por medio de:
Código Delphi
[-]
if not (Sender is TPanel) then
Exit;
Entonces ya puedes usar directamente:
Código Delphi
[-]
for I:= TPanel(sender).ControlCount - 1) downto 0 do
If TPanel(sender).Controls[i].Name<>'' then
If TPanel(sender).Controls[i].Name[1]='B' then
TPanel(sender).Controls[i].free;
Con esto ganarás en velocidad y eficiencia.
Saludos