I was wondering how you round numbers when you are outputting an answer to a label. I know it is .tostring("?"). I don't know what letter belongs where the ? is.
here is my code if it helps.
'Date: 10/8
'Peroid: 3
'Project Description: This project calculates your BMI
Public Class frmBmiMainPage
'Declaring Global Integers
'They take memory for the whole time th program is running
Private totalpeopleInte ger As Integer
Private totalpeopleaver ageDecimal As Decimal
Private Sub btnExit_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnExit.Click
'This button closes my program
Me.Close()
End Sub
Private Sub Label2_Click(By Val sender As System.Object, ByVal e As System.EventArg s)
End Sub
Private Sub Label3_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label3.Click
End Sub
Private Sub Label1_Click(By Val sender As System.Object, ByVal e As System.EventArg s)
End Sub
Private Sub frmBmiMainPage_ Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
End Sub
Private Sub btnCalculate_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCalculate.Cl ick
'Calculate BMI, Average BMI
'Declaring Our Variables
Dim poundsDecimal As Decimal
Dim feetDecimal As Decimal
Dim inchesDecimal As Decimal
Dim poundstokilogra msDecimal As Decimal
Dim inchestometersD ecimal As Decimal
Dim feetandinchesDe cimal As Decimal
Dim BMIDecimal As Decimal
Dim averageBMIDecim al As Decimal
Try
'Get Information from text boxes
poundsDecimal = Decimal.Parse(t xtPounds.Text)
feetDecimal = Decimal.Parse(t xtFeet.Text)
inchesDecimal = Decimal.Parse(t xtInches.Text)
'Do our calcuations
poundstokilogra msDecimal = poundsDecimal * 0.454
feetandinchesDe cimal = feetDecimal * 12 + inchesDecimal
inchestometersD ecimal = feetandinchesDe cimal * 0.0254
inchestometersD ecimal = inchestometersD ecimal ^ 2
BMIDecimal = poundstokilogra msDecimal / inchestometersD ecimal
totalpeopleaver ageDecimal += BMIDecimal
totalpeopleInte ger += 1
'Output our answers to Lables
lblOutput.Text = BMIDecimal
lblTotalPeople. Text = totalpeopleInte ger
averageBMIDecim al += totalpeopleaver ageDecimal / totalpeopleInte ger
lblAverageBMI.T ext = averageBMIDecim al
Catch ex As Exception
MessageBox.Show ("Please Input Data!", "Data Error", MessageBoxButto ns.OK, MessageBoxIcon. Error)
End Try
End Sub
Private Sub txtWeight_TextC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtPounds.TextC hanged
End Sub
Private Sub txtFeet_TextCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtFeet.TextCha nged
End Sub
Private Sub lblOutput_Click (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles lblOutput.Click
End Sub
Private Sub btnClear_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnClear.Click
'This button clears my project
lblOutput.Text = ""
txtPounds.Clear ()
txtInches.Clear ()
txtFeet.Clear()
End Sub
End Class
Thankyou.
here is my code if it helps.
'Date: 10/8
'Peroid: 3
'Project Description: This project calculates your BMI
Public Class frmBmiMainPage
'Declaring Global Integers
'They take memory for the whole time th program is running
Private totalpeopleInte ger As Integer
Private totalpeopleaver ageDecimal As Decimal
Private Sub btnExit_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnExit.Click
'This button closes my program
Me.Close()
End Sub
Private Sub Label2_Click(By Val sender As System.Object, ByVal e As System.EventArg s)
End Sub
Private Sub Label3_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Label3.Click
End Sub
Private Sub Label1_Click(By Val sender As System.Object, ByVal e As System.EventArg s)
End Sub
Private Sub frmBmiMainPage_ Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
End Sub
Private Sub btnCalculate_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCalculate.Cl ick
'Calculate BMI, Average BMI
'Declaring Our Variables
Dim poundsDecimal As Decimal
Dim feetDecimal As Decimal
Dim inchesDecimal As Decimal
Dim poundstokilogra msDecimal As Decimal
Dim inchestometersD ecimal As Decimal
Dim feetandinchesDe cimal As Decimal
Dim BMIDecimal As Decimal
Dim averageBMIDecim al As Decimal
Try
'Get Information from text boxes
poundsDecimal = Decimal.Parse(t xtPounds.Text)
feetDecimal = Decimal.Parse(t xtFeet.Text)
inchesDecimal = Decimal.Parse(t xtInches.Text)
'Do our calcuations
poundstokilogra msDecimal = poundsDecimal * 0.454
feetandinchesDe cimal = feetDecimal * 12 + inchesDecimal
inchestometersD ecimal = feetandinchesDe cimal * 0.0254
inchestometersD ecimal = inchestometersD ecimal ^ 2
BMIDecimal = poundstokilogra msDecimal / inchestometersD ecimal
totalpeopleaver ageDecimal += BMIDecimal
totalpeopleInte ger += 1
'Output our answers to Lables
lblOutput.Text = BMIDecimal
lblTotalPeople. Text = totalpeopleInte ger
averageBMIDecim al += totalpeopleaver ageDecimal / totalpeopleInte ger
lblAverageBMI.T ext = averageBMIDecim al
Catch ex As Exception
MessageBox.Show ("Please Input Data!", "Data Error", MessageBoxButto ns.OK, MessageBoxIcon. Error)
End Try
End Sub
Private Sub txtWeight_TextC hanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtPounds.TextC hanged
End Sub
Private Sub txtFeet_TextCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtFeet.TextCha nged
End Sub
Private Sub lblOutput_Click (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles lblOutput.Click
End Sub
Private Sub btnClear_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnClear.Click
'This button clears my project
lblOutput.Text = ""
txtPounds.Clear ()
txtInches.Clear ()
txtFeet.Clear()
End Sub
End Class
Thankyou.
Comment