Question : 'Day' is  a type and cannot be used as an expression

Can anybody see what is wrong with my code?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
        If Month(CDate(labelDateJOinedScheme.Text)) < Month(CDate(labelDOB.Text)) Or (Month(CDate(labelDateJOinedScheme.Text)) = Month(CDate(labelDOB.Text)) And Day(CDate(labelDateJOinedScheme.Text)) < Day(CDate(labelDOB.Text))) Then 
            AgeAtSchemeEntry = Year(CDate(labelDateJOinedScheme.Text)) - Year(CDate(labelDOB.Text)) - 1
        Else
            AgeAtSchemeEntry = Year(CDate(labelDateJOinedScheme.Text)) - Year(CDate(labelDOB.Text)) 
        End If

Answer : 'Day' is  a type and cannot be used as an expression

You are using old vb functions Month and day.

It would be better in .net to convert the dates in the text box to actual dates, assuming that the dates in the text boxes are valid dates, otherwise you may get errors.

1:
2:
3:
4:
dim JoinDate as Date = date.parse(labelDateJOinedScheme.Text)
dim dateOfBirth as date = date.parse(labelDOB.Text)
 
ageAtSchemeEntry = DateDiff(DateInterval.Year, dateofBirth, Joindate)
Random Solutions  
 
programming4us programming4us