[求助]程序有问题:想找出数组中两数相差在15以内的数
想找出数组中两数相差在15以内的数,这些数为不合格数,但是运行不出来请指教,程序如下,谢谢
Private Sub Command2_Click()
Dim bjh() As Variant
Dim tmax As Variant
bjh = Array(130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10)
tmax = 0
For i = LBound(bjh) To UBound(bjh) - 1
For j = i + 1 To UBound(bjh)
If (bjh(i) - bjh(j) >= 15) And (bjh(i) - bjh(j - 1) < 15) Then
If i - j > tmax Then
tmax = i - j
Print "不合格的有1--" & i & "," & j & "--" & UBound(bjh)
End If
End If
Print "tmax=" & tmax;
Next j
Next i
End Sub