Home > Software engineering >  Remove the lowest points average
Remove the lowest points average

Time:09-19

 
Private Sub Command1_Click ()
Dim Max As an Integer, min As Integer
Dim avg As Single, sum As Single
Max=0
Min=10
Dim ary (10) As an Integer
Dim As Integer I
For I=0 To 9
Controls (" text "& amp; I + 2). The Text=ary (I)
If ary (I) & gt; Max Then
Max=ary (I)
End the If
If ary (I) & lt; Min Then
Min=ary (I)
End the If
Next
Label2. Caption="removes a high score" & amp; Max
Label3. Caption="remove a minimum points" & amp; Min
Sum=sum + ary (I)
Avg=(sum - min - Max)/8
Label4. Caption="was the final score of the athletes" & amp; Avg
End Sub




Runtime, literally enter a number between 1-10 of 10, the result is that

There is no error

In addition, the code is tedious or inappropriate place, welcome criticism pointed out

Thank you,

CodePudding user response:

The
reference
Controls (" text "& amp; I + 2). The Text=ary (I)

This line has a problem, should, in turn, give ary numerical value assignment within the text,
The original poster had better make 10 text controls a control array, so you can simply write: ary (I)=val (text (I))
Also, ary (10) is in use, the best judges scoring is not necessarily an integer,

CodePudding user response:

One thousand which judge B hit 1.234 + 5.678 I score to knead?

CodePudding user response:

refer to the second floor zhao4zhong1 response:
one thousand which judges hit 1.234 + 5.678 B I score to knead?
miss zhao thinking is very meticulous

CodePudding user response:

reference qq574221329 reply: 3/f
Quote: refer to the second floor zhao4zhong1 response:

One thousand which judge B hit 1.234 + 5.678 I score to knead?
miss zhao thinking is very meticulous

So the verifier input value is a perennial legal the profession maintain the programmer will not be eliminated, the so-called AI

CodePudding user response:

reference 4 floor zhao4zhong1 response:
Quote: reference qq574221329 reply: 3/f

Quote: refer to the second floor zhao4zhong1 response:

One thousand which judge B hit 1.234 + 5.678 I score to knead?
miss zhao thinking is very meticulous

So the verifier input value is a perennial legal the profession maintain the programmer will not be eliminated, the so-called AI


Usually in text Lostfocus events, using IsNumeric function, if the range limitation, plus a range limit, such as the building of 0 ~ 10,
As zhao four teacher said so pack to force the judges, also had to turn a blind eye, harmonious, all according to the single

CodePudding user response:

Three or four
SAN she boss
XXXIV
36, oh no, again lose 2
.
The endless matter also

CodePudding user response:

Thank you for your bosses, after correction code is as follows:
 Private Sub Command1_Click () 
Dim Max As Single, min As Single
Dim avg As Single, sum As Single
Max=0
Min=10
Dim ary (10) As Single
Dim As Integer I
For I=0 To 9
Ary (I)=Val (Text2 (I). The Text)
If ary (I) & gt; Max Then
Max=ary (I)
End the If
If ary (I) & lt; Min Then
Min=ary (I)
End the If
Sum=sum + ary (I)
Next
Label2. Caption="removes a high score" & amp; Max
Label3. Caption="remove a minimum points" & amp; Min
Avg=(sum - min - Max)/8
Label4. Caption="was the final score of the athletes" & amp; Avg
End Sub




CodePudding user response:

The result of the "average", or deal with it,
The length of a string of decimal, don't feel funny?

 Label4. Caption="was the final score of the athletes:" & amp; The format $(avg, "#" 0.0) 

CodePudding user response:

Why not use the drop-down list to display the score

CodePudding user response:

references 9 f Mike_Squall response:
why not use the drop-down list to display the score

Feel the content of the list is too dense, not beautiful
  • Related