I`ve got a function searching for a spesific month in an array. The month is part of a full date like thisdd.mm.yyyy) I`ve got a text box, where I write a number representing a month, which is the input of the function which returns the position in the array for that specific month. The sorted array has been filled from "txtPerson.text" looking somthing like this:
Name
date
address
Phone
i.e
Adolf
14.02.1980
Duckstreet 5, ohio
555-89898
It seems to me that the function does not return the position in the array, Why not, what am I doing wrong?
Name
date
address
Phone
i.e
Adolf
14.02.1980
Duckstreet 5, ohio
555-89898
It seems to me that the function does not return the position in the array, Why not, what am I doing wrong?
Visual Basic:
' Ignore the fact that Month is a reserved word.
Structure individual
Dim name As String
Dim dates As String
Dim address As String
Dim Phone As String
End Structure
Dim person(8) As individual
.
.
Private Sub Button1_Click.....
Dim Temp as Integer
Temp = MonthSearch(cInt(txtNumber.text))
End Sub
.
.
.
Function MonthSearch(ByVal month As Integer) As Integer
Dim first, middle, last As Integer
first = 1
last = numPerson
Do While (first <= last)
middle = CInt((first + last) / 2)
Select Case CInt(CDate(person(middle).dates).Month)
Case Month
Return middle
Case Is > Month
last = middle - 1
Case Is < Month
first = middle + 1
Case Else
End Select
Loop
Return 0
End Function