Em um Módulo:
Function dhAge(dtmBD As Date, Optional dtmDate As Date = 0) _
As Integer
' This procedure is stored as dhAgeUnused in the sample
' module.
Dim intAge As Integer
If dtmDate = 0 Then
' Did the caller pass in a date? If not, use
' the current date.
dtmDate = Date
End If
intAge = DateDiff("yyyy", dtmBD, dtmDate)
If dtmDate < DateSerial(Year(dtmDate), Month(dtmBD), _
Day(dtmBD)) Then
intAge = intAge - 1
End If
dhAge = intAge
End Function
No VBA do Form:
Private Sub txtDataNasc_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Me.TxtDataNasc <> "" Then
TextBox2 = dhAge(TxtDataNasc)
Exit Sub
End If
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 07/06/2012 9:28 am