# Comparing Values

I'm taking an intro course to VB, any help would be appreciated.

I need to compare 3 values and take the two highest values to average them out. Thanks to anyone who views or replies.

• : I'm taking an intro course to VB, any help would be appreciated.
:
: I need to compare 3 values and take the two highest values to
: average them out. Thanks to anyone who views or replies.
:

[code]
Option Explicit

Private Sub Command1_Click()

Dim NUM(1 To 3) As Integer
'ASSIGN SOME NUMS
NUM(1) = 1
NUM(2) = 7
NUM(3) = 3

Dim i As Integer, j As Integer
Dim tmp As Integer
Dim MSG As String

MsgBox "Original no's=" & NUM(1) & "," & NUM(2) & "," & NUM(3)

'SIMPLE BUBBLE SORT, DESCENDING ORDER [hi-to-lo]
For i = 1 To 3
For j = 1 To 3
If NUM(i) > NUM(j) Then
tmp = NUM(i)
NUM(i) = NUM(j)
NUM(j) = tmp
End If
Next
Next

MsgBox "Sorted no's, hi-to-low=" & NUM(1) & "," & NUM(2) & "," & NUM(3)

tmp = (NUM(1) + NUM(2)) / 2
MsgBox "Average = (" & NUM(1) & "+" & NUM(2) & ")/2=" & tmp

End Sub

[/code]