Hi, I wrote these codes because I need to make a condition (as you can see). But Its sturks where its highlighted. Means giving this error message :
The name “A” does not existi n the current context
The name “B” does not existi n the current context
C#:
using System;
using System.Windows.Form
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txtResultA_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtResultA.Text) && !string.IsNullOrWhiteSpace(txtResultB.Text))
{
float A = 0;
float B = 0;
float.TryParse(txtResultA.Text, out A);
float.TryParse(txtResultB.Text, out B);
if (A > B)
{
txt_SoldForResultA.Text = (A - B).ToString("N2");
txt_SoldForResultB.Text = string.Empty;
}
else if (A < B)
{
txt_SoldForResultB.Text = (B - A).ToString("N2");
txt_SoldForResultA.Text = string.Empty;
}
}
}
private void txtResultB_TextChanged(object sender, EventArgs e)
{
txtResultA_TextChanged(sender, e);
}
}
}
Last edited by a moderator: