[Ann] IPv4 Subnet Calculator Class (Open Source)

Hello,

I have recently made my Subnet Calculator class for Xojo available as an open source project. I have included a demo app to help show off the Subnet Calculator Class’ capabilities.

You can clone or download this project at:
https://github.com/IntelligentVisibility/SubnetCalculator

If you have any questions please DM or email me.

Thank you,
Mike

Mike, thanks for making that available.

Just a quick FYI: BackgroundTasks False and DisableBackgroundTasks do exactly the same thing.

Thanks Kem!!! I wasn’t 100% sure if they were so I figured I would cover the bases :slight_smile: Ill remove one and thank you again.

Mind if I make some changes and submit it? Just cleanup, really.

Absolutely and I would appreciate it :slight_smile:

Pushed

Total newbie question: what do you use this for?

Calculating the IP (IP version 4) Address Network Subnet ranges.

http://compnetworking.about.com/od/workingwithipaddresses/a/subnetmask.htm

Markus I built a commercial product around this class for Network / Systems Engineers.
http://www.intelligentsubnetcalculator.com

Much appreciated Kem!

[quote=124883:@Kem Tekinay]Mike, thanks for making that available.

Just a quick FYI: BackgroundTasks False and DisableBackgroundTasks do exactly the same thing.[/quote]
Kem related to your changes… I was always under the impression that IF statemens were faster than Select Case statements. Is this not true?

Thank you again.

I think I tested this once and the answer, at the time, was yes. However, unless you are going to be using it in millions of iterations and speed is absolutely critical, I wouldn’t sacrifice code readability and maintenance for it. We are measuring the difference in milliseconds, after all.

Unfortunately when you search for a /30 or 255.255.255.252 you will need to iterate over 4 million subnets so speed is absolutely needed for that specific criteria. :slight_smile:

I just tested again and there is no difference in a compiled app. The two variations pitted against each other:

  for i as integer = 1 to 1000000
    dim x as integer = 3
    if x = 0 then
      msg = str( x )
    elseif x = 1 then
      msg = str( x )
    elseif x = 2 then
      msg = str( x )
    elseif x = 3 then
      msg = str( x )
    end if
  next

vs.

  for i as integer = 1 to 1000000
    dim x as integer = 3
    select case x
    case 0
      msg = str( x )
    case 1
      msg = str( x )
    case 2
      msg = str( x )
    case 3
      msg = str( x )
    end 
  next

Both took about 300 ms.

Thank you Kem for testing that!!

However, this variation (the one I replaced in your code) is slower:

  for i as integer = 1 to 1000000
    dim x as integer = 3
    if x = 0 then
      msg = str( x )
    else
      if x = 1 then
        msg = str( x )
      else
        if x = 2 then
          msg = str( x )
        else
          if x = 3 then
            msg = str( x )
          end if
        end if
      end if
    end if
  next