0
Reply

really simple i think?

Ask a question
james thomas

james thomas

17y
1.6k
1
First off guys im really new to programming and so this is probably really simple im just missing something. basicly the following code wont compile as the
variables fractOne, fractTwo and fractThree dont exist within the

private void transfer_Click(object sender, EventArgs e) area or is it called a namespace?

anyway i was hoping someone could take a look over my code and tell me a way of sharing or accessing those variable. Also any other critiques of my code would be great as im keen to learn.

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

namespace arb_calc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public void convGo_Click(object sender, EventArgs e)
{
double fOneTop = double.Parse(fractOneTop.Text);
double fOneBottom = double.Parse(fractOneBottom.Text);
double fractOne = fOneTop / fOneBottom + 1;
decOne.Text = fractOne.ToString("N2");

double fTwoTop = double.Parse(fractTwoTop.Text);
double fTwoBottom = double.Parse(fractTwoBottom.Text);
double fractTwo = fTwoTop / fTwoBottom + 1;
decTwo.Text = fractTwo.ToString("N2");

double fThreeTop = double.Parse(fractThreeTop.Text);
double fThreeBottom = double.Parse(fractThreeBottom.Text);
double fractThree = fThreeTop / fThreeBottom + 1;
decThree.Text = fractThree.ToString("N2");
}

private void transfer_Click(object sender, EventArgs e)
{
oddsSelectionOne.Text = fractOne.ToString();
oddsSelectionTwo.Text = fractTwo.ToString();
oddsSelectionThree.Text = fractThree.ToString();
}
}
}

cheers in advance

Jay