Calculation not displaying

I’m trying to make a BMI calculator for my class and for some reason the BMI wont display. It works for other equations tho. I tried math.pow and that didn’t work either
No description
5 Replies
FunkyMonkey
FunkyMonkeyOP4w ago
I don’t get any errors when running it either. Just the lblBMI.Text part doesn’t show the BMI.tostring part. If i make double BMI = weight / height(like in the // section); It WILL show. Makes no sense
SG97
SG974w ago
I suggest you debug, and figure out what value gets calculated if you're taking user input I suggest using $tryparse
MODiX
MODiX4w ago
When you don't know if a string is actually a number when handling user input, use int.TryParse (or variants, e.g. double.TryParse)
if (int.TryParse("123", out int number))
{
var total = number + 1;
Console.WriteLine(total); // output: 124
}
if (int.TryParse("123", out int number))
{
var total = number + 1;
Console.WriteLine(total); // output: 124
}
TryParse returns a bool, where true indicates successful parsing. - Avoid int.Parse if you do not know if the value parsed is definitely a number. - Avoid Convert.ToInt32 entirely, this is an older method and Parse should be preferred where you know the string can be parsed. Read more here
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
glhays
glhays3w ago
From my take all this should work correctly as far as your coding for calculate body mass indexes and assignability to the control. What no one can tell by this pic, is where the label controls visibility is set or how. More context might help us help you. 🤔

Did you find this page helpful?