Results 1 to 40 of 59

Thread: [RESOLVED] multiple range checking algorithm vb6

Threaded View

  1. #8
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: multiple range checking algorithm vb6

    Quote Originally Posted by axisdj View Post
    sorry guys, my fault for not giving more detail.

    That was what I was going to do, traverse the array until I find a match. But I would need to do 100's of these per second the first time th ip visits ( would save it in a list for quicker access later). So I guess what I am asking is there a fast way to set up the array so that it would be searched as fast as possible to find a range match.


    Thinking about it now, I could make the range Minimum number the index of the array??

    WP
    VB is very fast you can check against an array dozen of thousands of times per second.

    Just take your time to measure.... it is simple numericals.

    oh, and another thing.

    you really don't needs to convert it to decimals, normally the Internet is build up in pre-assigned ranges to ISPs and are all BASED on the first and second number.

    Don't use decimals.

    uses ranges this way (first*256)+second, so it still Integer value.

    so

    private const Total = 1000
    private LastInUse as integer
    private Base(0 to Total-1) as long
    private Top(0 to Total-1) as long

    then

    _ConnectionRequest
    dim x as integer, y as integer
    dim STRD as string
    dim num as long

    strd=.remoteIP

    x=instr(strd,".")
    y=instr(x+1,strd,".")
    num=val(mid$(strd,1,x-1)) * 256 + val(mid$(strd,x+1,y-(x+1)))

    if LastInUse>=0 then
    for x=0 to LastInUse

    if num>= base(x) and num <top(x) then ' Ok, is in USA.

    next x
    endif




    EDIT: But if you want it FASTER, I recommend you to use LOOK UP TABLES.

    IT is easy.



    private IsInUSA(0 to 255, 0 to 255) as boolean


    Configure the table one time.... TRUE if in USA, FALSE if not.


    then...

    _ConnectionRequest
    dim x as integer, y as integer
    dim STRD as string


    strd=.remoteIP

    x=instr(strd,".")
    y=instr(x+1,strd,".")

    if IsInUSA(val(mid$(strd,1,x-1)), val(mid$(strd,x+1,y-(x+1)))) then ' Is in USA.
    Last edited by flyguille; Aug 17th, 2017 at 02:56 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width