6 Replies - 1958 Views - Last Post: 17 March 2012 - 09:32 PM Rate Topic: -----

#1 bubba17   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 23-October 09

Windows Form Application help!

Post icon  Posted 14 November 2009 - 08:03 PM

I had to make this Windows Form Application where 2 digits are entered in a textbox and there will be an Add button and the results come out on a Label. This is what I have so far:


I don't think the numerals entered into the textboxes are being read by my program

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace pe07real
{
	public partial class Form1 : Form
	{
		int txtadd;
		int txtadd2;
		int txtmultiply;
		int txtmultiply2;

		public double txtAdd
		{
			get
			{
				return txtadd;
			}
		}

		public double txtAdd2
		{
			get
			{
				return txtadd2;
			}
		}

		public double txtMultiply
		{
			get
			{
				return txtmultiply;
			}
		}

		public double txtMultiply2
		{
			get
			{
				return txtmultiply2;
			}
		}


		
		public Form1()
		{
			InitializeComponent();
		}


		private void labelansMultiply_Click(object sender, EventArgs e)
		{
		 

		}

		private void textBoxMultiply_TextChanged(object sender, EventArgs e)
		{

		}

		private void Form1_Load(object sender, EventArgs e)
		{

		}

		public void buttonAdd_Click(object sender, EventArgs e)
		{
			string inValue;
			double ans;

			
			ans = (txtAdd + txtAdd2);


			inValue = label3.Text;

			label3.Text = String.Format("{0:G}", ans).ToString();

		}

		public void labelAnsAdd(object sender, EventArgs e)
		{

		}

		private void buttonMultiply_Click(object sender, EventArgs e)
		{
			string inValue;
			double ansM;


			ansM = txtMultiply * txtMultiply2;

			inValue = label1.Text;

			label1.Text = String.Format("{0:C}", ansM).ToString();
		}

		private void textBoxMultiply2_TextChanged(object sender, EventArgs e)
		{

		}

		private void textBoxAdd_TextChanged(object sender, EventArgs e)
		{

		}

		private void textBoxAdd2_TextChanged(object sender, EventArgs e)
		{

		}
	}
}



** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: Windows Form Application help!

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6872
  • View blog
  • Posts: 31,656
  • Joined: 10-May 07

Re: Windows Form Application help!

Posted 14 November 2009 - 08:06 PM

I don't see a main or winmain function. Are you certain this is C/C++ code? Looks more like Java.
Was This Post Helpful? 0
  • +
  • -

#3 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Windows Form Application help!

Posted 14 November 2009 - 08:09 PM

If you look at the "Programming Help" menu to your left you will see there is an option for "C#" which is my guess as to what you are writing here.

Am I right?

If I am you'll get better help there.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: Windows Form Application help!

Posted 14 November 2009 - 09:27 PM

Yes, this is C#. Moved there.
Was This Post Helpful? 0
  • +
  • -

#5 kstr   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 60
  • Joined: 19-October 09

Re: Windows Form Application help!

Posted 16 November 2009 - 07:15 AM

I'm not entirely sure what you are trying to do but take a look at this:

public void buttonAdd_Click(object sender, EventArgs e)
		{
			double answer = double.Parse(textBox1.Text) + double.Parse(textBox2.Text);
			label3.Text = String.Format("{0:G}", answer); 
		}

	   

		private void buttonMultiply_Click(object sender, EventArgs e)
		{
			double answer = double.Parse(textBox1.Text) * double.Parse(textBox2.Text);
			label3.Text = String.Format("{0:G}", answer); 




Would that do the trick?

Why are you using getters in your form class?
Was This Post Helpful? 0
  • +
  • -

#6 paintballer   User is offline

  • New D.I.C Head

Reputation: -6
  • View blog
  • Posts: 7
  • Joined: 17-March 12

Re: Windows Form Application help!

Posted 17 March 2012 - 09:24 PM

this is c# :gun_bandana: :nottalkingtoyou: :gun_bandana: :gun_bandana: :gun_bandana: :nottalkingtoyou: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :clover: :(!): :dangole: :scooter: :balloon: :walkman: >_< >.< :chinese: :sarcasm: :innocent: :rolleyes: :basecase: :smartass: :censored: :offtopic: :shuriken: :sorcerer: :bigsmile: :happybday: :surrender: :sweatdrop: :rolleyes2: :detective: :gunsmilie: :dozingoff: :dontgetit: :whatsthat: :bananaman: :whistling: :donatello: :red_indian: :001_icon16: :wheelchair: :helpsmilie: :withstupid: :online2long:
Was This Post Helpful? -5
  • +
  • -

#7 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6872
  • View blog
  • Posts: 31,656
  • Joined: 10-May 07

Re: Windows Form Application help!

Posted 17 March 2012 - 09:32 PM

Though your input is ... slightly appreciated, I don't think that the original poster from 2009 cares any longer. Please read & understand before posting to an older topic. Is the input really worth it? In this situation, no.

Also, rather than posting more emoticons than words, smash your self in the face with your keyboard. There really is no need for that.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1