Habilitar / Desabilitar Componentes

daniellsfirefox

13-11-2018 15:58:14

Boa tarde Pessoal, sou novo no fórum e mais novo ainda em desenvolvimento vba...
Gostaria de uma ajuda se possível para simplificar o código:

Código: Selecionar todos

Private Sub cboEquipamento_Change()
    If cboEquipamento.Text <> "" Then
    Me.cboAuto.Enabled = False
    Me.cboKm.Enabled = False
    Else
    Me.cboAuto.Enabled = True
    Me.cboKm.Enabled = True

End If
End Sub

Private Sub cboHs_Change()
    If cboHs.Text <> "" Then
    Me.cboAuto.Enabled = False
    Me.cboKm.Enabled = False
    Else
    Me.cboAuto.Enabled = True
    Me.cboKm.Enabled = True

End If
End Sub


Private Sub cboAuto_Change()
    If cboAuto.Text <> "" Then
    Me.cboEquipamento.Enabled = False
    Me.cboHs.Enabled = False
    Else
    Me.cboEquipamento.Enabled = True
    Me.cboHs.Enabled = True

End If
End Sub

Private Sub cboKm_Change()
    If cboKm.Text <> "" Then
    Me.cboEquipamento.Enabled = False
    Me.cboHs.Enabled = False
    Else
    Me.cboEquipamento.Enabled = True
    Me.cboHs.Enabled = True

End If
End Sub

Tenho um controle de equipamento e horas outro automóvel e km, quando selecionar equipamento ou horas tem que desabilitar automóvel e km e vice versa. Obrigado!

webmaster

13-11-2018 16:05:38

Para um iniciante, o código até que está muito bom. Ele está funcionando?

daniellsfirefox

13-11-2018 16:13:26

Rsrsrs, está funcionando sim... Porém acredito que deve ter algum jeito de simplificá-lo.