form新增一個按鈕,點選就是結果Private Sub Command1_Click()Dim i, j, k, sum, imax, iavg, a(1 To 10)j = 0: sum = 0: imax = 0: iavg = 0For i = 1 To 10 Do j = InputBox("請輸入第 " & i & " 個整數:") Loop While IsNumeric(j) = False a(i) = j sum = sum + j If j > imax Then imax = jNext iiavg = sum / 10For i = 1 To 9 For j = i + 1 To 10 If a(j) < a(i) Then k = a(j) a(j) = a(i) a(i) = a(j) End If Next jNext iFor i = 1 To 10 Print a(i)Next iEnd Sub
form新增一個按鈕,點選就是結果Private Sub Command1_Click()Dim i, j, k, sum, imax, iavg, a(1 To 10)j = 0: sum = 0: imax = 0: iavg = 0For i = 1 To 10 Do j = InputBox("請輸入第 " & i & " 個整數:") Loop While IsNumeric(j) = False a(i) = j sum = sum + j If j > imax Then imax = jNext iiavg = sum / 10For i = 1 To 9 For j = i + 1 To 10 If a(j) < a(i) Then k = a(j) a(j) = a(i) a(i) = a(j) End If Next jNext iFor i = 1 To 10 Print a(i)Next iEnd Sub