Have a look to the project and please correct me.

Discussion in 'Questions (Windows Mobile)' started by mozaharul, Oct 12, 2008.

  1. mozaharul

    mozaharul Active Member Licensed User

    Hi,
    In the attached project (with database), Table1 represents individual house hold and head name. Clicking a house hold will show the Date of birth (dob) of all members of that house hold in Table2.

    What I want:
    Calculation of individual member’s age and to keep those in an array variable, so could be use later in the program.

    What I did:
    Declared in Global sub an array variable agecal (0) in line-3
    Redefined it with “RowCount” of table2 in line-26
    And tried to calculate individual’s age in line-29
    But doesn’t calculate any thing !

    Please help.


    Regards
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should redefine the array with:
    Code:
    Dim agecal(rc)
    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.
     
  3. mozaharul

    mozaharul Active Member Licensed User

    Hi Erel,

    Thank you again for your time.


    regards,
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice