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 ?
Re: Conufused boolean comparation
Where is bHieraquia declared? Maybe it went out of scope. Do you have Option Explicit turned on?
Re: Conufused boolean comparation
How do you assign value to permTotal variable?
Re: Conufused boolean comparation
Please show more details of your code. It's seem that something wrong with your declaration..
Re: Conufused boolean comparation
Hi
permTotal boolean variable with (is true)
the code is inside form in load
Re: Conufused boolean comparation
You didn't answer my question. Do you use Option Explicit in the form? And, where is bHieraquia declared?
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.
Re: Conufused boolean comparation
Quote:
Originally Posted by
mutley
Hi
permTotal boolean variable with (is true)
the code is inside form in load
But where is it declared (this is just to concur baja's concern).
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
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.