tengo un problema similar y con sus experiencia de que manera creen que podría lograrlo.
Tengo este código y al utilizar el IndexOf este me manda un error "Grid exceded index"
Código Delphi
[-]
texto:=FVenta.EdVenta.Text;
IF GetTokenCount(texto,'%') = 2 then begin
if (EsStrunNumero(GetToken(texto,'%',1))) and (EsStrunNumero(GetToken(texto,'%',2)))then
begin
idesc:= StrToInt(GetToken(texto,'%',1)); scve:= GetToken(texto,'%',2); Fventa.SGVenta.Row := Fventa.SGVenta.Cols[1].indexOf(scve);
MessageDlg(scve, mtInformation,[mbOk], 0);
MessageDlg(Fventa.SGVenta.Cells[0,Fventa.SGVenta.Row], mtInformation,[mbOk], 0);
if scve = Fventa.SGVenta.Cells[0,Fventa.SGVenta.Row] then begin
importdesc:=StrToFloat(Fventa.SGVenta.Cells[6,Fventa.SGVenta.Row]); if idesc <> 0 then
begin
Desc:=1-idesc/100; import:=importdesc*Desc;
Fventa.SGVenta.Cells[5,Fventa.SGVenta.Row]:= IntToStr(idesc); end;
import2:=FormatFloat('#,##0.00',DM1.QDist.FieldByName('Precio').AsFloat); Fventa.SGVenta.Cells[3,Fventa.SGVenta.Row]:= import2;
import2:=FormatFloat('#,##0.00',import);
Fventa.SGVenta.Cells[6,Fventa.SGVenta.Row]:= import2;
if Fventa.EdImporte.Text <> '' then
begin
importotal:=StrToFloat(QuitaEn(Fventa.EdImporte.Text, ','));
importotal:=importotal+import;
import2:=FormatFloat('#,##0.00',importotal);
Fventa.EdImporte.Text:=import2;
If Fventa.EdCostoEnvio.Text = '' then
Fventa.EdTotal.Text:=import2
else
Fventa.EdTotal.Text:=FormatFloat('#,##0.00',importotal+StrToFloat(Fventa.EdCostoEnvio.Text));
end
else
begin
Fventa.EdImporte.Text:=import2;
If Fventa.EdCostoEnvio.Text = '' then
Fventa.EdTotal.Text:=import2
Else
Fventa.EdTotal.Text:=FormatFloat('#,##0.00',StrToFloat(import2)+StrToFloat(Fventa.EdCostoEnvio.Text) );
end;
MessageDlg(FVenta.EdVenta.Text, mtInformation,[mbOk], 0);
Fventa.EdVenta.Clear;
end
Else
begin
MessageDlg('El PRODUCTO solicitado no ha sido todavia ingresado', mtError,[mbOk], 0);
FVenta.EdVenta.Clear;
end;
end
Else
begin
MessageDlg('Revise su SINTAXIS', mtError,[mbOk], 0);
FVenta.EdVenta.Clear;
end;
end;
Lo que se quiere lograr es encontrar en una columna un string especifico y obtener su indice para realizar las operaciones y sustituir valores.
Saludos.