String cadena, a2, b2, c2;
int i, j, longitud, n;
double a, b, c, grueso, ancho, largo, volumen,suma=0;
for(i=1;i<=31;i++)
{
for(j=0;j<=31;j++)
{
cadena=StringGrid2->Cells[0][i];
longitud=cadena.Length();
a2=cadena.SubString(1,longitud);
b2=cadena.SubString(1,longitud);
b2=b2.Delete(1,2);
c2=cadena.SubString(1,longitud);
if(a2.IsEmpty()==true)
a=0;
else a=a2.Delete(2,longitud).ToDouble();
if(b2.IsEmpty()==true)
b=0;
else b=b2.Delete(2,2).ToDouble();
if(c2.IsEmpty()==true)
c=1;
else
c=cadena.Delete(1,longitud-1).ToDouble();
}
grueso=(b/c)+a;
if(StringGrid2->Cells[1][i].IsEmpty()==true)
ancho=0;
else ancho=StringGrid2->Cells[1][i].ToDouble();
if(StringGrid2->Cells[2][i].IsEmpty()==true)
largo=0;
else largo=StringGrid2->Cells[2][i].ToDouble();
if(StringGrid2->Cells[3][i].IsEmpty()==true)
n=0;
else n=StringGrid2->Cells[3][i].ToDouble();
volumen=((grueso*ancho*largo)/12)*n;
suma+=volumen;
if(volumen==0)
StringGrid2->Cells[4][i]="";
else
StringGrid2->Cells[4][i]=FormatFloat("0.000",volumen);
StringGrid2->Cells[5][1]=FormatFloat("0.000",suma);
StringGrid2->Cells[5][i+1]="";
Edit3->Text=FormatFloat("0.000",suma);
}