fix crash when entering non digits in the input fields

This commit is contained in:
Ilya 2020-05-05 12:13:28 +03:00
parent 211c0e834f
commit 0f05ce77d3
3 changed files with 9 additions and 11 deletions

View File

@ -36,19 +36,14 @@ namespace PhysFormuler
{
if (box.Text != "")
{
if (Convert.ToDouble(box.Text) != 0)
double number;
if (Double.TryParse(box.Text,out number))
{
return true;
}
else
{
return false;
return !double.IsNaN(number);
}
else return false;
}
else
{
return false;
}
else return false;
}
private void Update(string type)
@ -101,7 +96,7 @@ namespace PhysFormuler
if(IsReady(U, type))
{
Numbers.I = Numbers.U / Numbers.R;
I.Text = Math.Round(Numbers.I, 4).ToString();
I.Text = Math.Round(Numbers.I, 4).ToString();
}
if(IsReady(I, type))
{

View File

@ -10,4 +10,7 @@
<FallbackCulture>ru-RU</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
</Project>