Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15908

[RESOLVED] Ide0059

$
0
0
So I am getting a message when I do the following instruction:

Code:

if (txtUnitPrice.Text != "" && !decimal.TryParse(txtUnitPrice.Text, out decimal dec))
{
MessageBox.Show("Please enter a numeric value in the Price field or leave blank.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtUnitPrice.Focus();
return false;
}

"Unnecessary assignment of a value to 'dec'" which is not really unnecessary because TryParse() requires it. Is there a better way to do this, though?

Viewing all articles
Browse latest Browse all 15908

Latest Images

Trending Articles



Latest Images

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