[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 594: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 650: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1110: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1110: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1110: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5277: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5277: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5277: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
Fórum Xmaker • somar campo
Página 1 de 1

somar campo

Enviado: Maio 10th, 2012, 4:52 pm
por Paulo Campregher
Olá! tenho a seguinte situação
Placa Descrição Valor
0001 Balcão 10,00
0002 teclado 5,00

quero somar esse dois campos como faço?

um abraço

Re: somar campo

Enviado: Maio 14th, 2012, 9:01 am
por Gustavo
Olá,

Se você quiser somar o valor desses campo em um XnumEdit, poderá selecionar os registros que queira somar e em seguida fazer um for.

Nesse exemplo utilizamos o SMDBGrid e colocamos o código no evento OnChangeSelection.

var
i: Integer;
begin
total.value := 0;
if SMDBGrid1.SelectedRows.Count > 0 then
begin
with SMDBGrid1.DataSource.DataSet do
begin
for i := 0 to SMDBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(Pointer(SMDBGrid1.SelectedRows.Items[i]));
total.value:= total.value + tabglobal.Nome_tabela.FieldByName('nome_campo').AsFloat;
end;
end;
end
end;


Caso não seja isso que você quer fazer, nos explique melhor a situação.