Option Explicit Private Sub Command1_Click() Dim score As Integer Dim mid As Integer Dim l As Integer Dim h As Integer Dim a() As Integer a() = Array("45,46,51,58,64,68,77,85,89,98") l = LBound(a) h = UBound(a) score = Text1.Text Do While l < h mid = (l + h) / 2 If a(mid) <= score Then mid = l Else: If a(mid) > score Then mid = h End If Loop Text2.Text = mid Debug.Print mid End Sub If a(mid) <= score Then mid = l Else: If a(mid) > score Then mid = h End If
If a(mid) <= score Then mid = l else mid=h end if If a(mid) <= score Then mid = l Else If a(mid) > score Then mid = h End If
¸ÄÁË»¹ÊÇ»á³ö´í If a(mid) <= score Then mid = l Else mid = h End If