View Full Version : Can anyone help me understand this code?

05-04-2011, 03:10 AM
Can anyone help me understand how the following bit of code is working. Basically this code gets an age range from two input boxes on a form. It then selects clients from an XML file whose age is within these ranges. It does this by comparing the age range to a stored date of birth. I would like to understand exactly how this works but there are no comments, can anyone explain this? By the way I am a VB.net newb

Dim dob As Integer = 0
dob = DateDiff(DateInterval.Day, Convert.ToDateTime(String.Format("{0}-{1}-{2}", itm...<day>.Value, itm...<month>.Value, itm...<year>.Value)), Now)
Catch ex As Exception
dob = DateDiff(DateInterval.Day, Convert.ToDateTime(String.Format("{1}-{0}-{2}", itm...<day>.Value, itm...<month>.Value, itm...<year>.Value)), Now)
End Try

dob = Math.Floor(dob / 365)
If (IsNumeric(txtAgeFrom.Text) And IsNumeric(txtAgeTo.Text)) Then
If Not (dob >= txtAgeFrom.Text And dob <= txtAgeTo.Text) Then
Continue For
End If
End If