Results 1 to 10 of 10

Thread: Conufused boolean comparation

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Conufused boolean comparation

    Hi

    I am using the atribuition below

    Code:
     bHieraquia = InStr("GC", HierarquiaEstrutura) > 0 Or permTotal
    after I put bHieraquia in visible control in frame

    HTML Code:
    fraFiltrosB.Visible = bHieraquia
    same permTotal is true , ever fraFiltrosB.Visible is with value false

    Why ?

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Conufused boolean comparation

    Where is bHieraquia declared? Maybe it went out of scope. Do you have Option Explicit turned on?

  3. #3

  4. #4
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    282

    Re: Conufused boolean comparation

    Please show more details of your code. It's seem that something wrong with your declaration..
    I'm still on the path of learning....

  5. #5

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Conufused boolean comparation

    Hi
    permTotal boolean variable with (is true)

    the code is inside form in load

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Conufused boolean comparation

    You didn't answer my question. Do you use Option Explicit in the form? And, where is bHieraquia declared?

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Conufused boolean comparation

    mutley, baja_yu may be right on target and answering his question could be helpful.
    In the mean time, maybe read this FAQ topic on scope of variables.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

  9. #9

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Conufused boolean comparation

    Hi, Sorry
    Yes, I use Option Explicit in the form
    Code:
    Private Sub Form_Load()
        Dim sEstados As String
        Dim i As Integer
        Dim j As Integer
        Dim bHieraquia As Boolean
        Dim sStatus As String
    
        ' -----------------------------------------------
        bCtrl = True
        bCtrlHabilListas = True
    
        If mPermissao = "" Then
            MsgBox "Usuário não possui permissão cadastrada.", vbInformation, "Atenção!"
            Exit Sub
        End If
    
        Screen.MousePointer = vbHourglass
    
        '-- Inicializa Negocios como Fertilizantes ---------------
        lbxEventos(11).Selected(0) = True
        CodNegocio = "F"    ' FERTILIZANTE
        If CodNegocio = "F" Then FiltroNegocio = " and NG_FERTILIZANTE = 'S' "
        If CodNegocio = "M" Then FiltroNegocio = " and NG_MAT_PRIMA    = 'S' "
        If CodNegocio = "N" Then FiltroNegocio = " and NG_NUTRI_ANIMAL = 'S' "
        '-- -------------------------------------- ---------------
        bHieraquia = False
        bHieraquia = InStr("GC", HierarquiaEstrutura) > 0 Or permTotal
      
        fraFiltrosB.Visible = bHieraquia
        If bHieraquia Then
            fmeconvidados.Left = 360
            fmeconvidados.Top = 8520
        Else
            fmeconvidados.Left = 360
            fmeconvidados.Top = 7200
        End If
    
        lbxEventos(14).Visible = (InStr("GC", HierarquiaEstrutura) > 0) Or permTotal
        lblSupervisao.Visible = (InStr("GC", HierarquiaEstrutura) > 0) Or permTotal
        ' shpFiltro(16).Visible = lblSupervisao.Visible
    
        lbxEventos(13).Visible = (InStr("GC", HierarquiaEstrutura) > 0) Or permTotal
        lblCoordenacao.Visible = (InStr("GC", HierarquiaEstrutura) > 0) Or permTotal
        ' shpFiltro(15).Visible = lblCoordenacao.Visible
    
        lbxEventos(12).Visible = (InStr("G", HierarquiaEstrutura) > 0) Or permTotal
        lblDepartamento.Visible = (InStr("G", HierarquiaEstrutura) > 0) Or permTotal
        ' shpFiltro(14).Visible = lblDepartamento.Visible
    
        lbxEventos(11).Visible = permTotal
        lblNegocios.Visible = permTotal
        ' shpFiltro(13).Visible = permTotal
    
        ' -- Botão Grupos e Itens Visível só para o Marketing ----
        '    tbRelatorio.Buttons(5).Visible = permTotal
        '    tbRelatorio.Buttons(6).Visible = permTotal
    
        lblGrupos.Visible = permTotal
        ' shpFiltro(11).Visible = permTotal
        lbxEventos(9).Visible = permTotal
    
        lblItens.Visible = permTotal
        ' shpFiltro(12).Visible = permTotal
        lbxEventos(10).Visible = permTotal
    
        lblGrupos.Visible = permTotal
        ' shpFiltro(11).Visible = permTotal
        lbxEventos(9).Visible = permTotal
        lblItens.Visible = permTotal
        ' shpFiltro(12).Visible = permTotal
        lbxEventos(10).Visible = permTotal
        'fraFiltrosA.Height = IIf(permTotal, 6500, 4700)
        'fraFiltrosB.Top = IIf(permTotal, 7200, 5400)
        ' -- ------------------------------------------------ ----
    
        ' -- Preenche Lista de Marcas -------------------
        PreencheListaMarcas
        ' -- Preenche Lista de Marcas -------------------
        PreencheListaTipoEvento
        ' -- Preenche Lista de Canais -------------------
        PreencheListaCanais
        ' -- Preenche Lista de Canais -------------------
        PreencheListaCulturas
    
        If isOracle Then
            PreencheLista lbxAnoInicio, "SCETB_EVENTO", "distinct to_char(DT_INICIO_EVENTO, 'yyyy')", , , _
                          "desc", "1", , , "<Todas>"
    
            PreencheLista lbxEventos(2), "SCETB_EVENTO", "distinct trim(CD_ESTADO)", , _
                        " 1 = 1 and trim(CD_ESTADO) <> '   ' ", , , "<Todas>", , "<Todas>"
    
            PreencheLista lbxEventos(4), "SCETB_STATUS", "DS_STATUS", "CD_STATUS", _
                        " CD_STATUS < 10 ", , "ID_ORDEMSTATUS", "<Todas>", , "<Todas>"
    
            PreencheLista lbxEventos(5), "SCETB_RESPONSAVEL", "DS_RESPONSAVEL", _
                          "CD_RESPONSAVEL", " ID_ATIVO = 'S' " & FiltroNegocio, , _
                          "DS_RESPONSAVEL", "<Todas>", , "<Todas>"
            PreencheLista lbxEventos(9), "SCETB_GRUPO_ITENS", "DS_GRUPO", "CD_GRUPO", _
                        " 1 = 1 " & FiltroNegocio, , "DS_GRUPO", _
                          "<Todas>", , "<Todas>"
        Else
            PreencheLista lbxAnoInicio, "SCETB_EVENTO_S", "distinct Year(DT_INICIO_EVENTO)", , , _
                          "desc", "1", , , "<Todas>"
            lbxAnoInicio.Selected(0) = False
            lbxAnoInicio.Selected(1) = True
    
            PreencheLista lbxEventos(2), "SCETB_EVENTO_S", "distinct ltrim(CD_ESTADO)", , _
                        " 1 = 1 and ltrim(CD_ESTADO) <> '' ", , " 1 ", "<Todas>", , "<Todas>"
    
            PreencheLista lbxEventos(4), "SCETB_STATUS_S", "DS_STATUS", "CD_STATUS", _
                        " CD_STATUS < 10 ", , "ID_ORDEMSTATUS", _
                          "<Todas>", , "<Todas>"
    
            PreencheLista lbxEventos(5), "SCETB_RESPONSAVEL_S", "DS_RESPONSAVEL", _
                          "CD_RESPONSAVEL", " ID_ATIVO = 'S' " & FiltroNegocio, , _
                          "DS_RESPONSAVEL", "<Todas>", , "<Todas>"
    
            PreencheLista lbxEventos(9), "SCETB_GRUPO_ITENS_S", "DS_GRUPO", "CD_GRUPO", _
                        " 1 = 1 " & FiltroNegocio, , "DS_GRUPO", _
                          "<Todas>", , "<Todas>"
        End If
        ' -- Marca o primeiro ano na lista ou o atual se o primeiro for maior
        If lbxAnoInicio.ListCount > 1 Then
            lbxAnoInicio.Selected(0) = False
            For i = 1 To lbxAnoInicio.ListCount - 1
                If lbxAnoInicio.List(i) = Val(Format(Date, "YYYY")) Then
                    lbxAnoInicio.Selected(i) = True
                End If
            Next
        Else
            lbxAnoInicio.Selected(0) = True
        End If
    
        CarregaEstrutura
        For i = 0 To lbxEventos.Count - 1
            lbxEventos(i).Selected(0) = True
        Next
    
        ' *** Inicializa datas DE/ATE a partir dos anos selecionados na lista de anos *************
        InicializaDatasPeriodo
        ' Configurando a toolbar tbRelatorio
        tbRelatorio.Buttons("CRONOGRAMA").Value = tbrUnpressed
        tbRelatorio.Buttons("TABELADINAMICA").Value = tbrUnpressed
        tbRelatorio.Buttons("GRUPOSEITENS").Value = tbrUnpressed
    
        HabilitaShapes False
        HabilitaListas False
    
        bCtrl = False
        bCtrlHabilListas = False
        Screen.MousePointer = vbDefault
    End Sub

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Conufused boolean comparation

    bHieraquia should be false only in this scenario:
    InStr("GC", HierarquiaEstrutura) = 0 and permTotal=0/false
    You should check those values. Remember InStr() is case-sensitive

    Now if permTotal is True, see if you are hiding that control elsewhere in your project. Maybe in a click event of your listboxes or buttons? Form resize event? Search your project for: fraFiltrosB.Visible

    I don't see permTotal declared anywhere. Assume declared at top of your form or in a module.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width