Click here to Skip to main content
15,890,399 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionDownload Web page (aspx) with content / Webclient? Pin
SHCruz8-Dec-16 16:26
SHCruz8-Dec-16 16:26 
QuestionSelect columns access database Pin
Member 128225738-Dec-16 0:08
Member 128225738-Dec-16 0:08 
AnswerRe: Select columns access database Pin
Richard MacCutchan8-Dec-16 1:24
mveRichard MacCutchan8-Dec-16 1:24 
GeneralRe: Select columns access database Pin
Member 128225738-Dec-16 3:36
Member 128225738-Dec-16 3:36 
GeneralRe: Select columns access database Pin
Richard MacCutchan8-Dec-16 3:52
mveRichard MacCutchan8-Dec-16 3:52 
GeneralRe: Select columns access database Pin
Member 128225738-Dec-16 6:28
Member 128225738-Dec-16 6:28 
GeneralRe: Select columns access database Pin
Richard MacCutchan8-Dec-16 6:44
mveRichard MacCutchan8-Dec-16 6:44 
QuestionProgressbar feedback (one fill another) Pin
SHCruz5-Dec-16 22:49
SHCruz5-Dec-16 22:49 
C#
I'm trying to work with 3 progress bars where one fill another. Is associated to treenodes in treeview. When research precess is completed with each nodes at certain level, need be filling the progressbar associated to parent node. But I cant make to work correctly. I need help to understand the logic.


VB.NET
Private Sub AtualizaSubcategorias(ByVal execucao As BackgroundWorker)

    Dim pbar_step_n2 As Double = 0, pbar_total_n2 As Double = 0
    Dim pbar_step_n3 As Double = 0, pbar_total_n3 As Double = 0
    Dim pbar_step_n4 As Double = 0, pbar_total_n4 As Double = 0
    Dim pbar_alvo As String = "", menos3 As String

    '********************** TREEVIEW TEMPORÁRIA *************************
    Dim tree_temp As New TreeView
    'clona nodes da tree_menu
    Dim n As New TreeNode
    n = tree_menu.Nodes(0).Clone
    tree_temp.Nodes.Add(n)
    '********************************************************************

    '********************** SUBCATEGORIAS *******************************

    '---------------- NÍVEL 2 (FILHOS)

    pbar_alvo = "n2" 'define o progressbar da vez

    menos3 = pbar_alvo & "|@|" & "100"
    execucao.ReportProgress(-3, menos3)

    pbar_total_n2 = 0
    pbar_step_n2 = (pbar_n2.Maximum / categoriasPARAatualizar.Count)

    For Each n2 As TreeNode In tree_temp.Nodes(0).Nodes 'n1.Nodes 'filhas das principais

        If (execucao.CancellationPending = True) Then Exit For

        If categoriasPARAatualizar.Contains(n2.Tag.ToString) Then
            Dim catTitulo = Split(n2.Text.ToString, "{")
            execucao.ReportProgress(-1, catTitulo(0).ToUpper)
            Capturador(n2.Tag.ToString, 2, n2)
            If pbar_total_n2 >= pbar_n2.Maximum Then
                execucao.ReportProgress(pbar_n2.Maximum, pbar_alvo)
            Else

            End If

            '---------------- NÍVEL 3 (NETOS)

            pbar_alvo = "n3" 'define o progressbar da vez
            If n2.Nodes.Count = 0 Then
                menos3 = pbar_alvo & "|@|" & categoriasPARAatualizar.Count
                execucao.ReportProgress(-3, menos3)
                execucao.ReportProgress(pbar_n3.Maximum, pbar_alvo)
                pbar_total_n2 = pbar_total_n2 + pbar_step_n2
            Else
                menos3 = pbar_alvo & "|@|" & n2.Nodes.Count
                execucao.ReportProgress(-3, menos3)
                pbar_total_n3 = 0
                pbar_step_n3 = (pbar_step_n2 / n2.Nodes.Count)
                For Each n3 As TreeNode In n2.Nodes 'netas das principais
                    If (execucao.CancellationPending = True) Then Exit For
                    Capturador(n3.Tag.ToString, 2, n3)
                    If pbar_total_n3 >= pbar_n3.Maximum Then
                        execucao.ReportProgress(pbar_n3.Maximum, pbar_alvo)
                        pbar_total_n2 = pbar_total_n2 + pbar_step_n2
                    Else

                    End If

                    '---------------- NÍVEL 4 (BISNETOS)

                    pbar_alvo = "n4" 'define o progressbar da vez
                    If n3.Nodes.Count = 0 Then
                        menos3 = pbar_alvo & "|@|" & "100"
                        execucao.ReportProgress(-3, menos3)
                        execucao.ReportProgress(pbar_n4.Maximum, pbar_alvo)
                        pbar_total_n3 = pbar_total_n3 + pbar_step_n3
                    Else
                        menos3 = pbar_alvo & "|@|" & n3.Nodes.Count
                        execucao.ReportProgress(-3, menos3)
                        pbar_total_n4 = 0
                        pbar_step_n4 = (pbar_step_n3 / n3.Nodes.Count)
                        For Each n4 As TreeNode In n3.Nodes 'bisnetas das principais
                            If (execucao.CancellationPending = True) Then Exit For
                            Capturador(n4.Tag.ToString, 2, n4)
                            pbar_total_n4 = pbar_total_n4 + pbar_step_n4
                            If pbar_total_n4 >= pbar_n4.Maximum Then
                                execucao.ReportProgress(pbar_n4.Maximum, pbar_alvo)
                                pbar_total_n3 = pbar_total_n3 + pbar_step_n3
                            Else
                                execucao.ReportProgress(pbar_total_n4, pbar_alvo)
                            End If
                        Next 'n4
                    End If 'n4
                Next 'n3
            End If 'n3
        End If
    Next
    '**********************************************************************
    execucao.ReportProgress(-2, tree_temp)
End Sub

Private Sub subcategorias_BckGrndWorker_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles subcategorias_BckGrndWorker.ProgressChanged

    '------------ COMANDOS

    If e.ProgressPercentage < 0 Then
        Select Case e.ProgressPercentage
            Case -1 'alterar label
                lbl_categoria.Text = e.UserState 'atualiza label
            Case -2 'obter a tree temporaria, clonar para a tree_menu e apresentar-la
                tree_menu.Nodes.Clear()
                tree_menu = e.UserState
                Panel1.Controls.Add(tree_menu)
                tree_menu.Dock = DockStyle.Fill
                tree_menu.ExpandAll()
            Case -3 'definir o valor maximo do progressbar
                Dim splt = Split(e.UserState, "|@|")
                If UCase(splt(0)) = "N2" Then
                    pbar_n2.Maximum = Int(splt(1))
                ElseIf UCase(splt(0)) = "N3" Then
                    pbar_n3.Maximum = Int(splt(1))
                ElseIf UCase(splt(0)) = "N4" Then
                    pbar_n4.Maximum = Int(splt(1))
                End If
        End Select
    End If

    '------------ PROGRESSBAR

    If e.ProgressPercentage > 0 Then
        Select Case UCase(e.UserState)
            Case "N2"
                'atualiza barra de progresso
                pbar_n2.Value = e.ProgressPercentage
                If pbar_n2.Value = pbar_n2.Maximum Then pbar_n2.Value = 0
            Case "N3"
                'atualiza barra de progresso
                pbar_n3.Value = e.ProgressPercentage
                If pbar_n3.Value = pbar_n3.Maximum Then pbar_n3.Value = 0
            Case "N4"
                'atualiza barra de progresso
                pbar_n4.Value = e.ProgressPercentage
                If pbar_n4.Value = pbar_n4.Maximum Then pbar_n4.Value = 0
        End Select
    End If
End Sub

QuestionRe: Progressbar feedback (one fill another) Pin
CHill606-Dec-16 5:08
mveCHill606-Dec-16 5:08 
AnswerRe: Progressbar feedback (one fill another) Pin
SHCruz7-Dec-16 11:59
SHCruz7-Dec-16 11:59 
QuestionVB.net - Index was out of range. Must be non-negative and less than the size of the collection Listview Pin
Abung Salman2-Dec-16 16:46
Abung Salman2-Dec-16 16:46 
QuestionRe: VB.net - Index was out of range. Must be non-negative and less than the size of the collection Listview Pin
Richard MacCutchan2-Dec-16 22:04
mveRichard MacCutchan2-Dec-16 22:04 
AnswerDon't post your question in multiple forums Pin
Dave Kreskowiak3-Dec-16 3:26
mveDave Kreskowiak3-Dec-16 3:26 
AnswerRe: VB.net - Index was out of range. Must be non-negative and less than the size of the collection Listview Pin
Richard Deeming5-Dec-16 2:00
mveRichard Deeming5-Dec-16 2:00 
QuestionQuestion about Class Interaction Pin
hilli_micha1-Dec-16 10:32
hilli_micha1-Dec-16 10:32 
AnswerRe: Question about Class Interaction Pin
Richard Deeming1-Dec-16 11:00
mveRichard Deeming1-Dec-16 11:00 
GeneralRe: Question about Class Interaction Pin
hilli_micha1-Dec-16 11:10
hilli_micha1-Dec-16 11:10 
GeneralRe: Question about Class Interaction Pin
Richard Deeming1-Dec-16 11:18
mveRichard Deeming1-Dec-16 11:18 
GeneralRe: Question about Class Interaction Pin
hilli_micha2-Dec-16 18:38
hilli_micha2-Dec-16 18:38 
QuestionConvert VB to C# Pin
Pavlex429-Nov-16 7:00
Pavlex429-Nov-16 7:00 
AnswerRe: Convert VB to C# Pin
Wendelius29-Nov-16 7:25
mentorWendelius29-Nov-16 7:25 
GeneralRe: Convert VB to C# Pin
Pavlex429-Nov-16 8:05
Pavlex429-Nov-16 8:05 
GeneralRe: Convert VB to C# Pin
Wendelius29-Nov-16 8:22
mentorWendelius29-Nov-16 8:22 
SuggestionRe: Convert VB to C# Pin
Richard Deeming29-Nov-16 9:26
mveRichard Deeming29-Nov-16 9:26 
GeneralRe: Convert VB to C# Pin
Jon McKee2-Dec-16 17:02
professionalJon McKee2-Dec-16 17:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.