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

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Percorrer vbAcceleratorGrid, extrair e passar inf?
vilmarbr
Pontos: 2843
SAO PAULO
SP - BRASIL
Postada em 23/09/2008 18:57 hs         

Tem algum jeito melhor de se percorrer um vbAcceleratorGrid e extrair seus dados para passar para uma outra rotina ??

- Percorrer um grid, no meu caso vbAcceleratorGrid, com varios campos (células).

- Após percorrer todas linhas e colunas, jogar cada resultado das linhas (varias) em collection montando um array dentro da collection (campo#campo2#campon)

- Passar esta collection prum form de relatorio

- Neste form relatorio percorrer esta collection e jogar na visualizacao

Sub mnuRel_click()
    With grdDados
        For lngLinha = 1 To .Rows
            For lngColuna = 1 To .Columns
                strKeyColuna = .ColumnKey(lngColuna)
                Select Case strKeyColuna
               
                Case "ID"
                    strID = .CellText(lngLinha, lngColuna)
               
                Case "NOME"
                    strNome = .CellText(lngLinha, lngColuna)

'                Case "MUITOS OUTROS CAMPOS"
'                    strMUITOS OUTROS CAMPOS = .CellText(lngLinha, lngColuna)

                End Select
            Next
                       
            Call colItensGrid.Add(strID & "#" & strBolsa & "#" & strMUITOS OUTROS CAMPOS)

            'Monta o relatório de saldos
            Call MontarRelatorio(colItensGrid)
           
        Next
    End With
end sub

-----------
Sub MontarRelatorio(colItensGrid as object)
   for i = 1 to colItensGrid.count
   arrayDados = split(colItensGrid(i),"#",-1,1)
  
      for j = 0 to Ubound(arrayDados)
         strHTML = "<td>" & arrayDados(j) & "</td>"
      next
   next

'obs.: o relaório será montado num webcontrol dentro de um controle activex montado para relatorio.
end sub

     
vilmarbr
Pontos: 2843
SAO PAULO
SP - BRASIL
Postada em 24/09/2008 14:44 hs         
eu estou fazendo agora sem usar colecao, montando apenas um string com as celulas html e parece que ficou melhor Emoções
 
>> frmPrincipal
Private Sub mnuRelSaldos_Click()
    On Error GoTo mnuRelSaldos_Click_Error
   
    Dim lngLinha            As Long         'Linhas  do grdSaldos
    Dim lngColuna           As Long         'Colunas do grdSaldos
    Dim strKeyColuna        As String       'Nome (Key = ID) da coluna
    Dim strHTML             As String       'String HTML com células de tabela
    Dim colItensGrid        As Collection
   
    Set colItensGrid = New Collection
   
    'Campos do grdSaldos
    Dim strID               As String
    Dim strBolsa            As String
    Dim strNome             As String
 'outros campos
   
    With grdSaldos
        For lngLinha = 1 To .Rows
            For lngColuna = 1 To .Columns
                strKeyColuna = .ColumnKey(lngColuna)
                Select Case strKeyColuna
               
                Case "ID"
                    strID = .CellText(lngLinha, lngColuna)
               
                Case "BOLSA"
                    strBolsa = .CellText(lngLinha, lngColuna)
                   
                Case "NOME"
                    strNome = .CellText(lngLinha, lngColuna)
                   
 'outros campos
                End Select
            Next
                       
            'TESTE
            strHTML = strHTML & "<tr><td>" & strID & "</td><td>" & strBolsa & "</td><td>" & strNome & "</td></tr>"
           
        Next
    End With
   
    'Monta e mostra o Relatório de Saldos
    Call frmRelatorio.MontarRelatorio(strHTML)
    Call frmRelatorio.Show
    On Error GoTo 0
    Exit Sub
mnuRelSaldos_Click_Error:
    Call GerarLog("ERRO - mnuRelSaldos_Click of Form frmInterface - " & Err.Number & " - " & Err.Description)
End Sub

>> frmRelatorio
Public Sub MontarRelatorio(strHTMLCelulas As String)
    On Error GoTo MontarRelatorio_Error
    Dim strHTML As String 'HTML completo
   
    strHTML = "<html>" & vbCrLf _
            & "<head>" & vbCrLf _
            & "<title>Relatório</title>" & vbCrLf _
            & "</head>" & vbCrLf _
            & "<body>" & vbCrLf _
            & "<table id='tbRelSaldos' cellSpacing='1' cellPadding='1' width='100%' border='1' align='center'>" & vbCrLf _
            & strHTMLCelulas & vbCrLf _
            & "</table>" & vbCrLf _
            & "</body>" & vbCrLf _
            & "<html>"
    Call McReportCtrl1.ShowReport(App.Path, True, strHTML, "")
    On Error GoTo 0
    Exit Sub
MontarRelatorio_Error:
    Call GerarLog("ERRO - MontarRelatorio of Form frmRelatorio - " & Err.Number & " - " & Err.Description)
End Sub
     
Página(s): 1/1    

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