none
HeartBeat Calculator

    Question

  • am writing a C# Windows Forms application that displays your name, your date of birth, the target date and the total number of times that your heart has beat from the minute you were born, an struggling from were to start with this, if any one could help with me that would be great
    Friday, March 26, 2010 10:52 AM

Answers

  • That would be close to impossible to know, since the number of beats depends on your pulse. And your pulse varies over time (depends on physical activity, general health, stress and a bunch of other factors) and can differ a lot from one person to another.

    Sure you could calculate som kind of approximation based on some average pulse, but it would just be a wild guess at best.

     


    Mattias, C# MVP
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 6:17 AM
    Friday, March 26, 2010 11:53 AM
  • The heart beat will vary from person to person and year after year. So you can't get an exact figure.

    For developing this based on some fixed figure, say 80 beats in a minutes.

    Start by creating a Windows Form application.

    1. Add a date picker control and a button as shown below

    2. Update the calculate click event as follows

    private void button1_Click(object sender, EventArgs e)
            {
                DateTime birthDate = dateTimePicker1.Value;
                TimeSpan diff = DateTime.Now.Subtract(birthDate);
                double beats = diff.TotalMinutes * 80;
                MessageBox.Show("HearBeat Approximates to : " + beats.ToString(), "HearBeat", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

     

     

     

     



    Thanks,
    A.m.a.L
    Dot Net Goodies
    Don't hate the hacker, hate the code
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 6:17 AM
    Friday, March 26, 2010 12:00 PM
  • Other than needing to change total to a string when outputting the result the code will compile, but I'm not sure what you are putting in the TextBoxes.

    textBox4.Text = total.ToString();

    As mentioned earlier, a DateTimePicker would be suitable to input a date.  Or you can use a regular TextBox and parse the text using DateTime.Parse().  Once you have a DateTime object it is very easy to find the number of Years, Days, Seconds and so on by simply subtracting one from the other.

    TimeSpan difference = DateTime.Now - enteredDate;

    int numberOfDays = difference.Days;


    ---
    Happy Coding!
    Morten Wennevik [C# MVP]
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 6:17 AM
    Friday, March 26, 2010 2:20 PM

All replies

  • What sort of help do you need? :)

    Mattia Baldinger http://www.code-in.net/
    Friday, March 26, 2010 10:58 AM
  • You have clear idea of the requirements then Why struggling on where to start. If you want the complete code for this on how to do it put a post.

    I'll help you. Without knowing what kind of a help you need if I spend time on this, it'll be waste of time for both of us.

    :)

     

     

     

    Friday, March 26, 2010 11:40 AM
  • That would be close to impossible to know, since the number of beats depends on your pulse. And your pulse varies over time (depends on physical activity, general health, stress and a bunch of other factors) and can differ a lot from one person to another.

    Sure you could calculate som kind of approximation based on some average pulse, but it would just be a wild guess at best.

     


    Mattias, C# MVP
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 6:17 AM
    Friday, March 26, 2010 11:53 AM
  • The heart beat will vary from person to person and year after year. So you can't get an exact figure.

    For developing this based on some fixed figure, say 80 beats in a minutes.

    Start by creating a Windows Form application.

    1. Add a date picker control and a button as shown below

    2. Update the calculate click event as follows

    private void button1_Click(object sender, EventArgs e)
            {
                DateTime birthDate = dateTimePicker1.Value;
                TimeSpan diff = DateTime.Now.Subtract(birthDate);
                double beats = diff.TotalMinutes * 80;
                MessageBox.Show("HearBeat Approximates to : " + beats.ToString(), "HearBeat", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

     

     

     

     



    Thanks,
    A.m.a.L
    Dot Net Goodies
    Don't hate the hacker, hate the code
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 6:17 AM
    Friday, March 26, 2010 12:00 PM
  • Hi,

    Well, you would need input fields, and some way to display the result.  A button press can calculate the result.


    ---
    Happy Coding!
    Morten Wennevik [C# MVP]
    Friday, March 26, 2010 12:04 PM
  • Hi,

    Well, you would need input fields, and some way to display the result.  A button press can calculate the result.


    ---
    Happy Coding!
    Morten Wennevik [C# MVP]

    I thought of displaying it in a message box. Just giving some idea about how he can go ahead.

    Thanks,
    A.m.a.L
    Dot Net Goodies
    Don't hate the hacker, hate the code
    Friday, March 26, 2010 12:07 PM
  • at the moment all i have done is a simple form of 4 text boxs an a button with this code

     

    sing

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.ComponentModel;

    using

     

    System.Data;

    using

     

    System.Drawing;

    using

     

    System.Text;

    using

     

    System.Windows.Forms;

    namespace

     

    WindowsApplication1

    {

     

    public partial class Form1 : Form

    {

     

    public Form1()

    {

    InitializeComponent();

    }

     

    int day = 0;

     

    int dayBeats;

     

    int month = 0;

     

    int monthBeats = 0;

     

    int year = 0;

     

    int yearBeats = 0;

     

    int total = 0;

     

    private void button1_Click(object sender, EventArgs e)

    {

    day =

    int.Parse(textBox1.Text);

     

    // the number of days

    dayBeats = (day - 16 * 168000);

    month =

    int.Parse(textBox2.Text);

    monthBeats = (month - 9 * 3024000);

    year =

    int.Parse(textBox3.Text);

    yearBeats = (2032 - year * 36288000);

    total = (dayBeats + monthBeats + yearBeats);

    textBox4.Text = total;

    }

     

    }

    }

     

    p.s am bit of a novice just to point out

    Friday, March 26, 2010 12:11 PM
  • Are you getting any error? Able to compile the code?

    Thanks,
    A.m.a.L
    Dot Net Goodies
    Don't hate the hacker, hate the code
    Friday, March 26, 2010 12:17 PM
  • Other than needing to change total to a string when outputting the result the code will compile, but I'm not sure what you are putting in the TextBoxes.

    textBox4.Text = total.ToString();

    As mentioned earlier, a DateTimePicker would be suitable to input a date.  Or you can use a regular TextBox and parse the text using DateTime.Parse().  Once you have a DateTime object it is very easy to find the number of Years, Days, Seconds and so on by simply subtracting one from the other.

    TimeSpan difference = DateTime.Now - enteredDate;

    int numberOfDays = difference.Days;


    ---
    Happy Coding!
    Morten Wennevik [C# MVP]
    • Marked as answer by Roahn Luo Tuesday, March 30, 2010 6:17 AM
    Friday, March 26, 2010 2:20 PM