Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
So this is the PHP script :

PHP
<?php
$from = "192.168.1.1";
$to = "192.169.255.255";
// generate ip addrs
$arry1 = explode(".",$from);
$arry2 = explode(".",$to);
$a1 = $arry1[0]; $b1 = $arry1[1]; $c1 = $arry1[2]; $d1 = $arry1[3];
$a2 = $arry2[0]; $b2 = $arry2[1]; $c2 = $arry2[2]; $d2 = $arry2[3];
while( $d2 >= $d1 || $c2 > $c1 || $b2 > $b1 || $a2 > $a1){
if($d1 > 255){
$d1 = 1;
$c1 ++;
}
if($c1 > 255){
$c1 = 1;
$b1 ++;
}
if($b1 > 255){
$b1 = 1;
$a1 ++;
}
echo "$a1.$b1.$c1.$d1 <br>";
$d1 ++;
}
?>


And this is what i have made in VB.NET2005

VB
Dim fromip As String = "192.168.0.0"
            Dim toip As String = "192.168.255.255"
            Dim arry1 As String() = fromip.Split(".")
            Dim arry2 As String() = toip.Split(".")
            Dim a1 As String = arry1(0)
            Dim b1 As String = arry1(1)
            Dim c1 As String = arry1(2)
            Dim d1 As String = arry1(3)
            Dim a2 As String = arry2(0)
            Dim b2 As String = arry2(1)
            Dim c2 As String = arry2(2)
            Dim d2 As String = arry2(3)
            Dim coco As New StreamWriter("a.txt", True)
            Do While d2 >= d1 Or c2 > c1 Or b2 > b1 Or a2 > a1
                If d1 > 255 Then
                    d1 = 1
                    c1 += 1
                End If
                If c1 > 255 Then
                    c1 = 1
                    b1 += 1
                End If
                If b1 > 255 Then
                    b1 = 1
                    a1 += 1
                End If
                coco.WriteLine(a1 & "." & b1 & "." & c1 & "." & d1)
                d1 += 1
            Loop
            coco.Close()
        End If


It should stop at 192.168.255.255 but it stops at 192.168.3.2. Something is wrong and I cant understand what. In VB.NET 2010 works great with this code provided by a friend :

VB
Dim fromip As String = "192.168.0.0"
Dim toip As String = "192.168.255.255"
Dim a1 As Integer() = fromip.Split("."c).Select(Function(s) Integer.Parse(s)).ToArray
Dim a2 As Integer() = toip.Split("."c).Select(Function(s) Integer.Parse(s)).ToArray

Dim coco As New List(Of String)
While a2(3) >= a1(3) Or a2(2) > a1(2) Or a2(1) > a1(1) Or a2(0) > a1(0)
If a1(3) > 255 Then
a1(3) = 1
a1(2) += 1
End If
If a1(2) > 255 Then
a1(2) = 1
a1(1) += 1
End If
If a1(1) > 255 Then
a1(1) = 1
a1(0) += 1
End If
coco.Add(String.Join(".", New Integer() {a1(0), a1(1), a1(2), a1(3)}))
a1(3) += 1
End While

TextBox1.Lines = coco.ToArray

But this code does not work in VB.NET 2005.
Can you please help me ? Thanks in advance and for the time invested in viewing this question.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900