좋은 아침입니다. 멍청한 질문이 있습니다. 20 시간 동안이 일을했는데 약간의 도움이 필요합니다. 15 개의 이름과 숫자가 들어있는 배열이 있습니다. 평균값이 있고 200 개가 넘는 항목 수를 확인하고 레이블에 표시해야합니다.
내가 가진 것이 작동하지 않습니다.
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
Loop
objReader.Close()
Else
MsgBox(strFileError, , "Error")
Close()
End If
End Sub
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)
Next
intPatientAverage = intPatientAverage / _intCholesterolLevel.Length
For intIEvelated As Integer = 0 To _intCholesterolLevel.Length - 1
intEvelatedLevel = intEvelatedLevel < 200(intIEvelated)
Next
'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) & "."
End Sub
Thank you for any suggestions you can give me.
론 목사
이 루프의 논리에는 약간의 작업이 필요합니다. :)
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
바라건대, 작동 할 것입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다