473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can anyone help with this?

Hi,

I am creating a windows application showing name date of birth and number of heartbeats from date of birth to a particular targetdate. My program is showing name and date of birth but i cannot get the program to work out the calculations. i have declared the variables at the top as beats per day and beats per week etc, i was wondering if anyone can help me as on how to get the program to calculate all these values once the enter button is pressed? here is my code, many thanks

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace q3
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         int bpd;
  15.         int bpw;
  16.         int bpm;
  17.         int bpy;
  18.         int bted;
  19.         int enb;
  20.  
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void btnenter_Click(object sender, EventArgs e)
  27.         {
  28.             bpd = 70 * 23;
  29.             bpw = 1680 * 5;
  30.             bpm = 11760 * 6;
  31.             bpy = 47040 * 13;
  32.             bted = 564480 * 39;
  33.             enb = 22456560 + 16800;
  34.  
  35.  
  36.         }
  37.  
  38.  
  39.  
  40.         private void txtheartbeats_TextChanged(object sender, EventArgs e)
  41.         {
  42.             txtheartbeats.Text = "enb";
  43.         }
  44.  
  45.         private void txtname_TextChanged(object sender, EventArgs e)
  46.         {
  47.             txtname.Text = "John Smith";
  48.         }
  49.  
  50.         private void txtDob_TextChanged(object sender, EventArgs e)
  51.         {
  52.             txtDob.Text = "05/10/1990";
  53.  
  54.         }
  55.  
  56.         private void txtTargetdate_TextChanged(object sender, EventArgs e)
  57.         {
  58.             txtTargetdate.Text = "11/10/2020";
  59.         }
  60.  
  61.  
  62.  
  63.     }
  64. }
Apr 22 '10 #1
5 1286
GaryTexmo
1,501 Expert 1GB
It's obvious this is some kind of homework assignment and it's against forum policy for you to ask for help on this kind of thing. That said, you can ask for syntax help and it seems to me that you might not have a lot of programming experience.

I'd highly suggest you head over to the insights forum and read through the tutorials posted by Tlhintoq. http://bytes.com/topic/c-sharp/insights/, look for the Building an Application series.

Your calculations in the code you posted are all hard coded. You need to learn about getting user input and using it in calculations with variables.

That's all I can really do to help you... good luck!
Apr 22 '10 #2
Monomachus
127 Expert 100+
@GaryTexmo
I would also suggest using DateTimePicker controls for Dates and also when calculating the difference between Dates use TimeSpan class.
Apr 22 '10 #3
Frinavale
9,735 Expert Mod 8TB
I would strongly recommend that you name your variables something that is easier to understand. I tried to help with this but I couldn't tell what the following variables were representing:
Expand|Select|Wrap|Line Numbers
  1.          int bpd;
  2.          int bpw;
  3.          int bpm;
  4.          int bpy;
  5.          int bted;
  6.          int enb;
It's unfair to just post a bunch of code and say "it's not working can you figure it out" especially when we have no idea what your logic is supposed to do...or even what your variables mean.


Why do you think your application is not working?
Are you seeing any error messages?
If you are, what line is the error occurring on?
If you don't see an error message, what is your application doing or not doing?
What have you tried to fix the problem?
Have you tried stepping through your code with the debugger to see what's going on?

-Frinny
Apr 22 '10 #4
tlhintoq
3,525 Expert 2GB
I suspect your program is calculating just fine when you click the button.

Expand|Select|Wrap|Line Numbers
  1.  private void btnenter_Click(object sender, EventArgs e)
  2.         {
  3.             bpd = 70 * 23;
  4.             bpw = 1680 * 5;
  5.             bpm = 11760 * 6;
  6.             bpy = 47040 * 13;
  7.             bted = 564480 * 39;
  8.             enb = 22456560 + 16800; 
  9.         }
You just aren't doing anything with the values after you do the calculations. You do all the math, then exit the method.

Learning Visual Studio is not helping you with the coding of your homework, so here's a VS tip. Put a breakpoint on the first line of the button.click method. Then run the program. You should see your program stop on this line when you click the button. You will then have to press the F10 key to step through the method line by line. You will see the values of these variable in the locals and autos pallets.
Apr 22 '10 #5
tlhintoq
3,525 Expert 2GB
I would strongly recommend that you name your variables something that is easier to understand. I tried to help with this but I couldn't tell what the following variables were representing:
Expand|Select|Wrap|Line Numbers
  1.  int bpd;
  2.          int bpw;
  3.          int bpm;
  4.          int bpy;
  5.          int bted;
  6.          int enb
;
Frinny is right. ASCII characters are free, and there is no global shortage. You don't have to conserve on letters when creating your variables. When you or someone else comes back to work on your program a year from now
BeatsPerMinute is a lot more descriptive than bpm
Apr 22 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: asdf sdf | last post by:
i have an install issue with moinmoin on win2k. i've tried the mailing list, but it appears to be a very low traffic, low subscriber list. can i get a reality check? is anyone using moinmoin in...
1
by: Simon Harvey | last post by:
Hi chaps, Does anyone know if the beast is going to release Visual Tools for office to work with Visual Studio 2002 and not just 2003, or are they quite happy to shaft those that supported them...
1
by: Greg Steele | last post by:
Does anyone have a copy or know where I can get an installation executable for chiliReports 2.0 from chili! soft? The company I'm working for bought a copy several years ago, then moved their...
0
by: james | last post by:
Hi guys! I´ve got a centerd table on my site with a black 1 pixel border. What i would like to do is to add a drop shadow to the table. Anyone know if it's possible to create a drop shadow for a...
162
by: Isaac Grover | last post by:
Hi everyone, Just out of curiosity I recently pointed one of my hand-typed pages at the W3 Validator, and my hand-typed code was just ripped to shreds. Then I pointed some major sites...
13
by: penguin732901 | last post by:
Checking back for discussions, there was a lot of talk about 2000 being slower than 97, but not so much lately. What is the latest opinion? Anyone care to set up a poll for how many NG members...
3
by: Jozef | last post by:
Hello, Has anyone here used the Visual Studio 2003 Office Developers Extensions? I'm wondering if the package and deployment wizard is any better than it's XP / 2002 counterpart. I already...
1
by: Leveridge Systems INC | last post by:
We need help with ASP.net work in a Solomom env. Or know anyone ? .. we can reward in cash. -- John D Allen. CEO & President. Leveridge Systems INC.
2
by: Bruno Alexandre | last post by:
Hi guys, does anyone know where is the Website used in the MSDN "Lear ASP.NET 2.0 with Jeff Prosise" (http://msdn.microsoft.com/asp.net/beta2/multimedia/default.aspx) events? The website used...
31
by: Jim Hubbard | last post by:
I am downloading the REALbasic 5.5 demo and was just wondering if anyone else had tried it. I am tired of Microsoft constantly changing things and breaking backward compatibility ON PURPOSE. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.