modlinear.bas

来自「Visual Basic 6 大学教程的代码」· BAS 代码 · 共 19 行

BAS
19
字号
Attribute VB_Name = "modLinear"
' Code module modLinear.bas
Option Explicit

Function LinearSearch(a() As Integer, key As Integer) As Integer
   Dim x As Integer

   For x = LBound(a) To UBound(a)

      If a(x) = key Then
         LinearSearch = x   ' Return index
         Exit Function
      End If

   Next x

   LinearSearch = -1        ' Value not found
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?