I have recently spent some time trying to figure out how to write a function that would take in an IP range, and return all the IPs in between. I have found quite a few examples, but all of those, were actually getting the IP range within a full subnet. i.e: 192.168.2.1/255.255.255.0 what I wanted, was a function that would give me the IPs between a range of IPs like the following:
192.168.1.50 – 192.168.2.35
Since I was scripting with Kixtart, I wrote the function in that language, though, if you know your way around VB, this could fairly easily be translated over.
The function I wrote is dependent on a UDF from the Kixtart UDF collection (find the EnumIPRange Function)
The following is the code for the function wrapper that would get the IP range:
; Author: Georges Khairallah (email@example.com)
; Description: Function that allows the input of an IP range and returns the list of IPs in an array
; Dependencies: UDF: EnumIPRange from http://Kixtart.org/UDF
; Returns: Array with the IP listing
; $Network = "10.10.0.0"
; $Mask = "255.255.248.0"
; $StartIP = "10.10.3.3"
; $EndIP = "10.40.6.20"
; $IPList = GetIPListing($Network,$Mask,$StartIP,$EndIP)
; For Each $i in $IPList
; $i ?
Dim $sipIX, $eipIX, $i
Dim $aIPRange 
$IPRange = EnumIPRange($Network, $Mask)
$sipIX = AScan($IPRange,$StartIP)
$eipIX = AScan($IPRange,$EndIP)
$IXCounter = 0
For $i = $sipIX to $eipIX
$aIPRange[$IXCounter] = $IPRange[$i]
$IXCounter = $IXCounter + 1
ReDim Preserve $aIPRange[$IXCounter - 1]
$GetIPListing = $aIPRange
Hope you find this bit of code useful.