This Small Basic program code creates a simple BMI calculator user interface. It displays text boxes to enter a user's weight in kilograms and height in centimeters. When the return key is pressed, it calculates the BMI based on the values entered and displays the result. It also determines the user's health status based on their BMI range and displays it using different colors.
This Small Basic program code creates a simple BMI calculator user interface. It displays text boxes to enter a user's weight in kilograms and height in centimeters. When the return key is pressed, it calculates the BMI based on the values entered and displays the result. It also determines the user's health status based on their BMI range and displays it using different colors.
This Small Basic program code creates a simple BMI calculator user interface. It displays text boxes to enter a user's weight in kilograms and height in centimeters. When the return key is pressed, it calculates the BMI based on the values entered and displays the result. It also determines the user's health status based on their BMI range and displays it using different colors.
Sub UpdateResult w = Math.Abs(Controls.GetTextBoxText(lblweightbox) * 1) h = Math.Abs(Controls.GetTextBoxText(lblheightbox) * 1)/100 If h = 0 Then BMI = "-" Else BMI = w/ (h*h) BMI = Math.Round(BMI*100/100) EndIf Shapes.SetText(lblResult, BMI) ShowStatus() EndSub
'Define subroutin for showing status of health
Sub ShowStatus Shapes.Remove(lblstatus) If BMI <> "-" Then If BMI < 20 Then status = "Under Weight" color = "Blue" ElseIf BMI <= 25 then status = "Normal" color = "LimeGreen" Else status = "Over Weight" color = "Red" EndIf GraphicsWindow.BrushColor = color 'Shapes.SetText(lblstatus, status) lblstatus = Shapes.AddText(status) Shapes.Move (lblstatus, 75, 118) GraphicsWindow.BrushColor = "Black" EndIf EndSub