【文章內(nèi)容簡介】
0 Option Base 1 Private Function Find( a( ) As Single,x As Single) As Integer Dim n%,p% n=Ubound( a ) p = 1 Do While p n And x a(p) p = p + 1 Loop If If p = n And a(p) x Then p = 0 Find=p End Function 方法二: Private Sub Command1_Click() Dim b(), k%, n% b = Array(1, 3, 5, 7, 9, 2, 4) k = Val(InputBox(輸入要查找的關(guān)鍵值)) Call search(b(), k, n) If n = 0 Then MsgBox (找到的位置為 amp。 n) Else MsgBox (找不到) End Sub Sub search(a(), ByVal key%, ByRef index%) Dim i% For i = LBound(a) To UBound(a) If key = a(i) Then index = i Exit Sub End If Next i index = 1 End Sub 5. 判斷回文數(shù)過程;P140,443 Private Function huiwen(str As String) Dim i As Integer, l As Integer str = Text1 l = Len(str) For i = 1 To l / 2 If Mid(str, i, 1) Mid(str, l i + 1, 1) Then = str amp。 不是回文數(shù) Else = str amp。 是回文數(shù)