It sure *is* faster than your Lookup-Routine (which I've written according to your "instructions").
If you think you can do better than that, I'd surely want to see some code from *you*.
What we have currently, regarding your approach is only a "paper-tiger", there's no Copy&Pastable
demo - or even better - a zipped Demo-Project from you anywhere.
I for my part would surely like to see, how you fill up that huge Lookup-Array of yours properly.
To make it somewhat easier for you, I've now extracted the 88314 US-RangeRecords from the
DataSet my larger Demo is using, and one can download it here:
http://vbRichClient.com/Downloads/USRangesDetailed.zip
It contains a normal CSV-File (
USRangesDetailed.csv, with IPfrom,IPto per Line) -
but also a Raw-CurrencyArray-File, called USRangesDetailed.bin, which one can load this way:
Code:
Private USRanges() As Currency
Sub InitRangeArray(FileName As String)
ReDim USRanges(0 To FileLen(FileName) \ 8 - 1)
Dim FNr As Long: FNr = FreeFile
Open FileName For Binary Access Read As FNr
Get FNr, , USRanges
Close FNr
End Sub
After the Init-Routine above was called, USRanges has an Ubound of 88314*2-1 and contains the sorted entries of the
88314 US-RangeRecords as numeric values, the IPFrom-entries sitting at the even Indexes, the IPTo-entries at the odd IndexPositions.
(mainly thought for those who want to try themselves at a Binary-Search-based algorithm against that Array).
Would surely like to see some code from you, which got the Lookup-Arrays filled with that detailed set of US-Ranges
(your choice, whether you read the data from the *.csv or the *.bin-file).
I've mentioned that because my code is faster and takes less memory *despite* offering full country-resolution...
If I reduce the Size of my DataSet to "US-Ranges only", then I'd expect results far better than 1 µsec per IPCheck-call.
Nothing holds you back to reformat it to your liking, it's not that much code after all... <shrug>
As for understanding it though, ...from how you post and interact with other developers (ignoring proof delivered by code) -
I'd think you are still quite young and inexperienced (comparably), so don't expect "immediate results" just by looking at it...
Olaf