I am trying to make a really simple application that takes some numbers, does some calculations and outputs an answer, but I can't seem to get it right. I understand it has something to do with scope. It's the last part of the code I get an error on. (The name 'lopm' does not exist in the current context). How can I make the different variables available outside of the "fogmassa" context so that I can show them to the user?
Any other comments on the code?
Thanks in advance.
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 fogmassa
{
public partial class fogmassa : Form
{
int kakellength = 1;
int kakelwidth = 1;
int fogwidth = 1;
public fogmassa()
{
InitializeComponent();
if (txtLength.Text != "")
{
kakellength = Convert.ToInt32(txtLength.Text);
}
if (txtWidth.Text != "")
{
kakelwidth = Convert.ToInt32(txtWidth.Text);
}
if (txtFogWidth.Text != "")
{
fogwidth = Convert.ToInt32(txtFogWidth.Text);
}
}
public void function_lopmeter()
{
int lopm = ((1 / (kakelwidth + fogwidth)) + (1 / (kakellength + fogwidth)));
}
private void label1_Click(object sender, EventArgs e)
{
}
private void txtFogWidth_TextChanged(object sender, EventArgs e)
{
}
private void btnCalc_Click(object sender, EventArgs e)
{
lblLopM.Text = ("Löpmeter fog " + lopm + " m");
}
}
}
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 23 November 2010 - 05:19 AM

New Topic/Question
Reply
MultiQuote











|