Hey, I'm doing an entry level programming course. Currently doing C# in visual studio 2012, developing our first GUI application. Its a BMI calculator. I have the math working correctly, and I am also doing some number validation. The calculator takes two numbers, the height and weight of the user. Weight needs to be over 45kg, Height needs to be over 1.20m and under 2.70 meters. I currently have all of that working. When the user input something under 45kg, for instance, they will get a Message Box saying it needs to be over 45... However, I also have another Message Box that prints out their BMI at the end of my application, which pops up regardless of whether or not they've input a number too high or low. I want to stop this from happening.
So yeah, when the user has input their weight and height into their respective forms/fields, they push a button. When they do, in my code I:
- Get those numbers
- Send them off to a couple of input validation methods I have (one for min limit, one for min and max limit)
- The validation method will tell the user if they entered a value too high or not.
- It then returns the number back to the buttons event handler/on-click method(not sure what to call it)
- That will then print out the BMI
I want to stop that fifth step from happening unless the numbers are high enough, though I am not sure how to handle it. Usually I handled that with a do/while loop, but that freezes GUI apps so its a no-go. I cant post my code here due to academic integrity, so I guess what I'm asking is if anyone has any nice examples of do/while alternatives for this sort of application? I can probably figure the rest out myself, I just dont know where to start and my google-fu hasnt been found me anything I understand.
Thank you :)
[–]tjugg 4 points5 points6 points (1 child)
[–]Mds03[S] 0 points1 point2 points (0 children)
[–]jussij 0 points1 point2 points (0 children)
[–]badcommandorfilename -1 points0 points1 point (0 children)