Página 1 de 1

Ajuda com cálculo no GetBox

Enviado: 28 Out 2014 15:39
por Softwhouse
Alguém saberia informar como se faz um cálculo no GetBox automáticamente? Preciso que o terceiro GetBox seja preenchido sem ter que teclar o botão.

Código: Selecionar todos


#include "minigui.ch"

Function Main
Local Qtd:=Valor:=TotItem:=0


Define Window Form_1 ;      
       At 0,0;
       Width 300;
       Height 250;
       Title 'Getbox Demo' ;
       Main
       
       Define Label Label_Quantidade
              Col 010
              Row 020
              AutoSize .T.
              Value 'Quantidade'
       End Label
       
       Define GetBox Gbox_Quantidade
              Col 100
              Row 020
              Width 30
              AutoSize .T.
              Value Qtd
              Picture '99999'
       End GetBox
       
       Define Label Label_Valor
              Col 010
              Row 060
              AutoSize .T.
              Value 'Unitário'
       End Label
       
       Define GetBox Gbox_Valor
              Col 100
              Row 060
              Width 70
              AutoSize .T.
              Value Valor
              Picture '@E 99,999.99'
       End GetBox
       
       Define Label Label_Total
              Col 010
              Row 100
              AutoSize .T.
              Value 'Total'
       End Label
       
       Define GetBox Gbox_Total
              Col 100
              Row 100
              Width 75
              AutoSize .T.
              Value TotItem
              Picture '@E 999,999.99'
              Action {||Totaliza(Form_1.Gbox_Quantidade.Value,Form_1.Gbox_Valor.Value)}
       End GetBox
       
       
End Window

Form_1.Center
Form_1.Activate

Return Nil

Static Function Totaliza(nValor1,nValor2)
nTotItem:=Form_1.Gbox_Total.Value:=nValor1*nValor2
Return(nTotItem)


Obrigado.

Ajuda com cálculo no GetBox

Enviado: 28 Out 2014 17:53
por Toledo
Fernando, tenta fazer o seguinte:

Trocar:

Código: Selecionar todos

     Action {||Totaliza(Form_1.Gbox_Quantidade.Value,Form_1.Gbox_Valor.Value)}
Por:

Código: Selecionar todos

     When {||Totaliza(Form_1.Gbox_Quantidade.Value,Form_1.Gbox_Valor.Value)}
Altere também a função Totaliza():

Código: Selecionar todos

Static Function Totaliza(nValor1,nValor2)
Form_1.Gbox_Total.Value:=nValor1*nValor2
Return .T.
Abraços,

Ajuda com cálculo no GetBox

Enviado: 29 Out 2014 09:10
por Softwhouse
Obrigado Toledo, retirei Action e usei somente When, funcionou perfeitamente.