You should redefine the array with:
The complete sub should be:
Code:
Sub Table1_SelectionChanged (ColName, Row)
If table1.SelectedRow >=0 Then
i=table1.SelectedRow
txthpidselect.Text=table1.Cell("HPID",i)
cmd.CommandText="select dob from member where hpid="&table1.Cell("HPID",i)
cmd.ExecuteTable("table2",0)
rc=table2.RowCount
Dim agecal(rc) ' array variable "agecal" is redefined here.
For i=0 To table2.RowCount-1
agecal(i)= Int(((calendar1.Value-DateParse(table2.Cell("dob",i)))/cTicksPerDay)/365.25)
Next
End If
End Sub
BTW, you can call DateFormat under App_Start instead of calling it each time.