Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

The name '' does not exist in the current context.

$
0
0

I have a form with multiple labels that have currency values and I have a button that sums the totals in another label.  I am trying to check for null values, but now I can't add the values because the variable is outside the scope of the method.  At least I beleive that's why I'm getting the error.

private void cmdcalculate_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(lbl85x11bwsub.Text))
            {
                string s = lbl85x11bwsub.Text;
                decimal value = decimal.Parse(s, NumberStyles.Currency);

            }
            
            decimal total = 0;
            total += (value);
            lblsubtotal.Text = total.ToString("C");          
        }


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>