USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Somar Coluna no VB
Danderson
SÃO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 12/04/2008 18:12 hs            
Amigos, estou iniciando na programação e estou com um problema....tenho que somar os valores de uma coluna...é um grid acoplado no form.....éu peguei o fonte e estou fazendo as alterações que preciso....o código que tenho é este....
 
'Retorna fórmula direta campo VALOR ICMS NF VENDA, tabela NF_VENDA
Private Function Pit_0017F9() As Double  ' {* Apelidos *} 700
Dim Sgvlricmsnfvenda As Double
If Empresas![Tipo icms empresa] <> "TRADICIONAL" Then
   Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
Else
   If Clientes![Uf fatura cliente] = "SP" Then
      Sgvlricmsnfvenda = Round(Itens_nf_venda![Vlr icms iten nf venda])
   ElseIf Clientes![Uf fatura cliente] <> "SP" And Clientes![Tipo cliente] = "JURÍDICA" And(Clientes![Inscrição rg cliente] = "ISENTA" Or Clientes![Inscrição rg cliente] = "EM ANDAMENTO") Then
      Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
   ElseIf Clientes![Uf fatura cliente] <> "SP" And Clientes![Tipo cliente] = "FÍSICA" Then
      Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
   ElseIf Clientes![Uf fatura cliente] <> "SP" And Clientes![Tipo cliente] = "JURÍDICA" And Clientes![Inscrição rg cliente] > 1 Then
      Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
   End If
End If

 Pit_0017F9 = Sgvlricmsnfvenda  'Deve retornar um número
 
End Function
 
 
o problema está no código em vermelho......c puderem me ajudar...

Pr. Daniel
   
Tiranossauro
DOIS IRMÃOS
RS - BRASIL
ENUNCIADA !
Postada em 12/04/2008 22:06 hs            
Qual a mensagem que está dando ?
Talvez seja problema no encadeamento de if ... talvez isto ajude
 
Private Function Pit_0017F9() As Double  ' {* Apelidos *} 700
Dim Sgvlricmsnfvenda As Double
If Empresas![Tipo icms empresa] <> "TRADICIONAL" Then
   Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
Else
   If Clientes![Uf fatura cliente] = "SP" Then
      Sgvlricmsnfvenda = Round(Itens_nf_venda![Vlr icms iten nf venda])
   Else
      If Clientes![Tipo cliente] = "JURÍDICA" And(Clientes![Inscrição rg cliente] = "ISENTA" Or Clientes![Inscrição rg cliente] = "EM ANDAMENTO") Then
         Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
      Else
         If Clientes![Tipo cliente] = "FÍSICA" Then
            Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
         Else
            if Clientes![Tipo cliente] = "JURÍDICA" And Clientes![Inscrição rg cliente] > 1 Then
               Sgvlricmsnfvenda = Round(((Nf_venda![Base icms nf venda] * Nf_venda![Icms perc nf venda] )/100), 2)
            end if  
         End If
      End if
   END IF
End If
Pit_0017F9 = Sgvlricmsnfvenda  'Deve retornar um número
 
End Function
   
Danderson
SÃO PAULO
SP - BRASIL
ENUNCIADA !
Postada em 13/04/2008 10:35 hs            
Da forma como está, ele não dá mensagem de erro, apenas o calculo fica errado, ele não está somando a coluna, pega apenas a última linha da coluna e arredonda o valor.

Pr. Daniel
   
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2025   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página