Author: Android | Posted on: 12/26/2008 12:05:20 AM | Views : 272

I want to identify the country of my website users and, after doing quite a lot of research, have almost found a solution - but I need some help getting over one final problem.

I have found a free IP-To-Country database at http://ip-to-country.webhosting.info/ and have found some vb code to use it at http://bkendall.biz/projects/iptocountrynet/. My thanks and appreciation to webhosting.info and Barnabas Kendall for getting me this far.

The problem I have is with just one function, GetCountryCode, in Barnabas' code. The code is as follows:

Public Shared Function GetCountryCode(ByVal IP As Long) As String
Dim Index As Integer = Array.BinarySearch(_Ranges, IP, New RangeFinder)
If Index > -1 Then
Return _Ranges(Index).Country
End If
End Function

First of all, I get a warning that this function doesn't return a value on all code paths. That I can resolve with an Else statement, but the main problem is with the 2nd line, ...

Go to the complete details ...