VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Calculate BMI (Body Mass Index), requires a simple input file created in notepad.

by the doctor (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Fri 1st August 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Calculate BMI (Body Mass Index), requires a simple input file created in notepad.

API Declarations


Dim weight(5) As Single
Dim Height1(5) As Single
Dim optweight(5) As String
Dim optweight2(3) As String
Dim counter As Integer
Dim bmi(5) As Single
Dim occurence(5) As Integer

Rate Calculate BMI (Body Mass Index), requires a simple input file created in notepad.



'
'
'exit the program
'
'
End
End Sub
Private Sub cmdstart_Click()
data_input Height1(), weight()
calculate_bmi weight(), bmi(), Height1()
calculate_weightbmi optweight2(), bmi(), optweight(), occurence()
display_results_bmi Height1(), weight(), bmi(), optweight2(), occurence()
End Sub
Private Sub data_input(ByRef Height1() As Single, weight() As Single)
                Open "input2bmi.txt" For Input As #1
            For counter = 1 To 5
        Input #1, Height1(counter), weight(counter)
    Next
Close #1
'
'
End Sub

Private Sub calculate_bmi(ByRef weight() As Single, bmi() As Single, Height1() As Single)
For counter = 1 To 5

    bmi(counter) = weight(counter) / Height1(counter) ^ 2
    Next
End Sub
Private Sub calculate_weightbmi(ByRef optweight2() As String, bmi() As Single, optweight() As String, occurence() As Integer)
'
Dim counternew As Integer
'
'
optweight2(1) = "underweight"
optweight2(2) = "ideal weight"
optweight2(3) = "overweight"

For counter = 1 To 5
    Select Case bmi(counter)
        Case Is < 18.5
            optweight(counter) = "underweight"
         Case Is >= 25
            optweight(counter) = "overweight"
                Case Is >= 18.5 < 25
            optweight(counter) = "ideal weight"
        End Select
    Next
'
'calculate how many pupils scored in each band
'
For counternew = 1 To 3
    For counter = 1 To 5
        If optweight2(counternew) = optweight(counter) Then
    occurence(counternew) = occurence(counternew) + 1
End If
Next
Next
'
End Sub
Private Sub display_results_bmi(ByRef Height1() As Single, weight() As Single, bmi() As Single, optweight2() As String, occurence() As Integer)
            picout.Print "Height in meters"; Tab(30); "Weight in kilometers"; Tab(70); "BMI"
'
        For counter = 1 To 5
    picout.Print Height1(counter); Tab(30); weight(counter); Tab(70); FormatNumber(bmi(counter), 1)
Next
'
'display the club member weight analysis results
'
            picdisplay.Print "category"; Tab(20); "number of members"; vbCrLf
'
'
        For counter = 1 To 3
    
    picdisplay.Print optweight2(counter); Tab(20); occurence(counter)
Next
'
End Sub



Download this snippet    Add to My Saved Code

Calculate BMI (Body Mass Index), requires a simple input file created in notepad. Comments

No comments have been posted about Calculate BMI (Body Mass Index), requires a simple input file created in notepad.. Why not be the first to post a comment about Calculate BMI (Body Mass Index), requires a simple input file created in notepad..

Post your comment

Subject:
Message:
0/1000 characters