引入: 自定義

 

Which(指令, 數值) 是用來在一堆數值內找到符合條件的數,並回傳。其中指令">" 代表找出最大值,"<" 代表找出最小值。

]Function Which(ByVal Command As String, ByVal Input As Array) As Object

]If (Input Is Nothing) Then

]Return 0

]End If

]Which = 0

]Dim ReSelect As Integer = 0

]Dim ReCase As Integer = 0

]Select Case Command

]Case ">"

]ReCase = 1

]ReSelect = 1

]Case "<"

]ReCase = -1

]ReSelect = 1

]End Select

]If (Command Like "*?%") Then

]ReSelect = 2

]Dim CharArray As Char() = Command.ToCharArray

]Dim Result As String = Nothing

]For i1 As Integer = LBound(CharArray) To UBound(CharArray) - 1 Step 1

]Result &= CharArray(i1)

]Next

]ReCase = Val(Result)

]End If

]Select ReSelect

]Case 1

]Which = Input(LBound(Input))

]For i1 As Integer = LBound(Input) To UBound(Input) Step 1

]If (Stick(Input(i1), Which) = ReCase) Then

]Which = Input(i1)

]End If

]Next

]Case 2

]Dim Least As Object = Input(LBound(Input))

]Dim Most As Object = Input(LBound(Input))

]For i1 As Integer = LBound(Input) + 1 To UBound(Input) Step 1

]Empire(Input(i1), Least, Most)

]Next

]Which = Input(LBound(Input))

]For i1 As Integer = LBound(Input) To UBound(Input) Step 1

]If (((((Input(i1) - Least) / (Most - Least)) - (ReCase / 100)) ^ 2) ^ (1 / 2) < ((((Which - Least) / (Most - Least)) - (ReCase / 100)) ^ 2) ^ (1 / 2)) Then

]Which = Input(i1)

]End If

]Next

]End Select

]Return Which

]End Function

文章標籤
全站熱搜
創作者介紹
創作者 GPhettoH 的頭像
GPhettoH

歇息,等待明日的天空

GPhettoH 發表在 痞客邦 留言(0) 人氣(3)