[RESOLVIDO].Módulo

Valdecirrk

06-09-2013 12:55:54

Criei este código no módulo, como faço para ele funcionar?

Sub resultado()

If Label11.Caption <> "" Then

Label9.Caption Label10.Caption + Label11.Caption = 111
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 112 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 113 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 211 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 121 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 212 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 311 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 122 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 131 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 221 Then
Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 223 Then
Label22.Caption = "Risco Alto - Prioridade Alta de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 313 Then
Label22.Caption = "Risco Alto - Prioridade Alta de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 321 Then
Label22.Caption = "Risco Alto - Prioridade Alta de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 322 Then
Label22.Caption = "Risco Alto - Prioridade Alta de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 123 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 132 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 213 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 222 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 231 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 232 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 312 Then
Label22.Caption = "Risco Moderado - Prioridade Média de Mudança"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 323 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 331 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 332 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 141 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 242 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 341 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 114 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 214 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else
If Label9.Caption + Label10.Caption + Label11.Caption = 314 Then
Label22.Caption = "Risco Crítico - Prioridade Muito Crítica"
Else

End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
If Label22.Caption = "Risco Baixo - Prioridade Baixa de Mudança" Then
Label9.BackColor = vbGreen
Label10.BackColor = vbGreen
Label11.BackColor = vbGreen
Label9.ForeColor = vbBlack
Label10.ForeColor = vbBlack
Label11.ForeColor = vbBlack
Else
If Label22.Caption = "Risco Moderado - Prioridade Média de Mudança" Then
Label9.BackColor = vbYellow
Label10.BackColor = vbYellow
Label11.BackColor = vbYellow
Label9.ForeColor = vbBlack
Label10.ForeColor = vbBlack
Label11.ForeColor = vbBlack
Else
If Label22.Caption = "Risco Alto - Prioridade Alta de Mudança" Then
Label9.BackColor = vbRed
Label10.BackColor = vbRed
Label11.BackColor = vbRed
Label9.ForeColor = vbWhite
Label10.ForeColor = vbWhite
Label11.ForeColor = vbWhite
Else
If Label22.Caption = "Risco Crítico - Prioridade Muito Crítica" Then
Label9.BackColor = vbBlack
Label10.BackColor = vbBlack
Label11.BackColor = vbBlack
Label9.ForeColor = vbWhite
Label10.ForeColor = vbWhite
Label11.ForeColor = vbWhite

End If
End If
End If
End If




End Sub

Mikel Silveira Fraga

11-09-2013 23:11:57

Valdecirrk, boa noite.

Pela lógica, seu código deveria estar funcionando, mas acredito que o erro esteja na forma como você esta realizando a concatenação entre as Label's.

Veja o exemplo abaixo:

- No primeiro código, parece que seria utilizado um If, mas faltaram as instruções If ... Then.

Código: Selecionar todos

Label9.Caption Label10.Caption + Label11.Caption = 111
- Neste segundo código, a estrutura da instrução If esta correta, mas o processo de concatenação que você utilizou, é para o MS-Access e não para o MS-Excel.

Código: Selecionar todos

If Label9.Caption + Label10.Caption + Label11.Caption = 112 Then
R: Substitua os símbolos + pelo &.

Código: Selecionar todos

If Label9.Caption & Label10.Caption & Label11.Caption = 112 Then
Realize estes testes e veja se vai funcionar. Caso não de certo, envie um arquivo modelo para facilitar na análise do código, ok.

Abraços e bons estudos.