Hello,
I have a function that is supposed to add values to a list if a certain condition is true. You will see from my code that the result returned by a function is checked to see if it is less then 30. This value represents a distance expressed as miles. If it is less than 30 then it will add the associated postcode pulled from the database to the list. What seems to be happening at present, however, is that postcodes for values greater than 30 are being added to the list and I have no idea why. Could someone please tell me what I'm doing wrong?
I have a function that is supposed to add values to a list if a certain condition is true. You will see from my code that the result returned by a function is checked to see if it is less then 30. This value represents a distance expressed as miles. If it is less than 30 then it will add the associated postcode pulled from the database to the list. What seems to be happening at present, however, is that postcodes for values greater than 30 are being added to the list and I have no idea why. Could someone please tell me what I'm doing wrong?
Do While myReader2.Read() lat2 = myReader2("lat").ToString() lon2 = myReader2("lng").ToString() unit = "M" Dim return_distance As String = distance(lat1, lon1, lat2, lon2, unit) If return_distance.length <> 1 Then trimmed_distance = return_distance.SubString(0,4) Else trimmed_distance = return_distance End If Dim converted_distance As Integer converted_distance = CINT(trimmed_distance) If converted_distance <= 30.00 Then postcode_match.Add(myReader2("outcode").ToString()) End If Loop Dim find_postcodes() As String = postcode_match.ToArray myReader2.Close()
Last edited by a moderator: