Alterar vária textbox ao mesmo tempo
Enviado: Sáb Ago 25, 2012 5:50 am
Olá
Tenho este código numa userform (dentro de um evento listview_click) que verifica em 5 textbox se a data inserida é anterior à data actual.
O que eu gostaria de saber é como posso simplificar o código. Quero fazer o mesmo noutra userform que tem mais de 10 textbox e assim o código torna-se muito extenso.
Obrigado
Ioncila
Tenho este código numa userform (dentro de um evento listview_click) que verifica em 5 textbox se a data inserida é anterior à data actual.
O que eu gostaria de saber é como posso simplificar o código. Quero fazer o mesmo noutra userform que tem mais de 10 textbox e assim o código torna-se muito extenso.
Código: Selecionar todos
'verificar a data de validade dos documentos
Dim CurrDate As Date
CurrDate = Now - 1
If txtValDss < CurrDate Then
txtValDss.ForeColor = vbRed
txtValDss.Font.Bold = True
Else: txtValDss.ForeColor = vbBlack
End If
If txtValDrf < CurrDate Then
txtValDrf.ForeColor = vbRed
txtValDrf.Font.Bold = True
Else: txtValDrf.ForeColor = vbBlack
End If
If txtValSrc < CurrDate Then
txtValSrc.ForeColor = vbRed
txtValSrc.Font.Bold = True
Else: txtValSrc.ForeColor = vbBlack
End If
If txtValSat < CurrDate Then
txtValSat.ForeColor = vbRed
txtValSat.Font.Bold = True
Else: txtValSat.ForeColor = vbBlack
End If
If txtValAlv < CurrDate Then
txtValAlv.ForeColor = vbRed
txtValAlv.Font.Bold = True
Else: txtValAlv.ForeColor = vbBlack
End If
Ioncila