Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Alex Passos

Calcular a idade no vb.net

Recommended Posts

Veja se te ajuda:

 

Public Function Age(ByVal Birthdate As System.DateTime) As LongTryDim CurrentDate As System.DateTime = System.DateTime.TodaySelect Case Month(Birthdate)	Case Is < Month(System.DateTime.Today)		Age = DateDiff("YYYY", Birthdate, Now())	Case Is = Month(CurrentDate)		 Select Case Day(Birthdate)			 Case Is < Day(CurrentDate)				Age = DateDiff("YYYY", Birthdate, Now())			 Case Is = Day(CurrentDate)				Age = DateDiff("YYYY", Birthdate, Now())			 Case Is > Day(CurrentDate)				  Age = DateDiff("YYYY", Birthdate, Now()) - 1		 End Select	Case Is > Month(CurrentDate)		Age = DateDiff("YYYY", Birthdate, Now()) - 1	Case Else		Age = 0End SelectCatch ex As System.Exception	'Error handling code does hereEnd TryEnd Function

Visite meu blog e assine meu feed RSS. Sempre há alguma dica por lá.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Juliano.. como eu faço esse DateDiff no C#??? ele nao tem essa função nativa como no VB...[]'s

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.