Good Morning, I have a dumb question, I have been at this for 20 hours and I need a little help Please
I have an array that has 15 names and numbers in it. I have the average, and I need to find out how many of entries are over 200 and display in a label.
what I have is not working:
Public Shared _intSizeOfArray As Integer = 14
Public Shared _strLastName(_intSizeOfArray) As String
'Private _strFirstName(_intSizeOfArray) As String
Public Shared _intCholesterolLevel(_intSizeOfArray) As Integer
Private Sub frmPatientCholesterollevels_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' This Load event reads the patient text file And initializes an instance
' of the StreamReader object.
' Declare Variables.
Dim objReader As IO.StreamReader
Dim strPatients As String = "patients.txt"
Dim intCount As Integer = 0
Dim strFileError As String = "The file is not available.
Please restart the application when the file is availble"
' Verify the patient.txt file exists.
If IO.File.Exists(strPatients) Then
objReader = IO.File.OpenText(strPatients)
' Read the file line by line until the file is completed.
Do While objReader.Peek <> -1
_strLastName(intCount) = objReader.ReadLine()
'_strFirstName(intCount) = objReader.ReadLine()
_intCholesterolLevel(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1
MsgBox(strFileError, , "Error")
Private Sub btnLabResults_Click(sender As Object, e As EventArgs) Handles btnLabResults.Click
' This Click Event displays the number of patients who have an elevalted Cholesterol
' level over 200 and displays the information in the results form and copies the information
' to a USB Drive and a second text file located at e:\consult.txt. It also displays the
' average cholesterol rate of the complete patient text file.
' Declare variables.
Dim intPatientAverage As Double
Dim intEvelatedLevel As Integer
For intIAverage As Integer = 0 To _intCholesterolLevel.Length - 1
intPatientAverage = intPatientAverage + _intCholesterolLevel(intIAverage)
intPatientAverage = intPatientAverage / _intCholesterolLevel.Length
For intIEvelated As Integer = 0 To _intCholesterolLevel.Length - 1
intEvelatedLevel = intEvelatedLevel < 200(intIEvelated)
'display the labels with the results
lblAveragePatients.Text = "The Average Cholesterol Level for Today is: " &
FormatNumber(intPatientAverage, 1) & "."
lblElveatedLevel.Text = "The Number of Patients With a Cholesterol Level Above 200 is: " &
FormatNumber(intEvelatedLevel, 1) & "."
Thank you for any suggestions you can give me.
I would say that the logic in this loop needs a little work. :)
For intIEvelated As Integer = 0 To _intCholesterolLevel.Length - 1 intEvelatedLevel = intEvelatedLevel < 200(intIEvelated) Next
For intIEvelated As Integer = 0 To _intCholesterolLevel.Length - 1 Dim patientCholesterolLevel As Integer = _intCholesterolLevel(intIEvelated) If patientCholesterolLevel > 200 Then intEvelatedLevel += 1 End If Next
Hopefully, it should work.