Thread: calculting different inputs

  1. #1
    Registered User wayko's Avatar
    Join Date
    Sep 2001
    Posts
    28

    calculting different inputs

    i want that a person input the year he/she was born
    that is inputted into an edit box called IDC_year with a member variable of double m_Year
    the current year is located on top with a group box called IDC_CURRENT_AGE with a member variable of CButton m_Current_Age

    I added a private called m_Your_Age
    I initialized it with m_Your_Age = 2001;

    I initialized m_Year with NULL

    now i want that when the person hit submit the year that was put in m_Year to be subtracted from m_Current_Age

    void CAgeDlg::OnCancel()
    {
    // TODO: Add your control notification handler code here
    CString s;
    s.Format("You are %.0f years old",m_Your_Age);
    MessageBox(s, "Your age is...");
    CDialog::OnCancel();
    }






    void CAgeDlg::CalculateAge()
    {
    if (m_Year < 2001)
    {
    (m_Your_Age -= m_Year);
    }
    }

    void CAgeDlg::OnSubmit()
    {
    // 1.
    (m_Your_Age -= m_Year);

    // 2.
    CalculateAge();

    // 3.
    CString s;
    s.Format("You are %.0f years old", m_Your_Age);

    m_Current_Age.SetWindowText(s);
    }
    hello its me Wayko

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    As long as you've attached m_Year to your edit control (with the Class Wizard), just call UpdateData(TRUE) before calling CalculateAge().
    zen

  3. #3
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    yea... so what's the problem?

    or do you just want to show off your code?

    Oskilian

  4. #4
    Registered User wayko's Avatar
    Join Date
    Sep 2001
    Posts
    28

    Talking

    it worked

    is there a way to clear the number and return it to its original amount without leaving the screen?
    hello its me Wayko

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I validate these inputs?
    By Kyeong in forum C Programming
    Replies: 1
    Last Post: 10-19-2008, 02:20 PM
  2. checking inputs meets multiple conditions
    By 60beetle60 in forum C Programming
    Replies: 5
    Last Post: 04-19-2008, 08:25 AM
  3. I need help with validation for two inputs
    By KarrieWojo in forum C Programming
    Replies: 14
    Last Post: 12-20-2007, 11:55 AM
  4. Taking inputs at Command Line
    By Stephenf in forum C++ Programming
    Replies: 1
    Last Post: 09-28-2005, 02:33 AM
  5. Getting multiple inputs using cin
    By edk in forum C++ Programming
    Replies: 2
    Last Post: 09-13-2001, 02:34 PM