Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
So this is the PHP script :
 
<?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
 
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 :
 
    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 6-Oct-12 23:02pm

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

  Print Answers RSS
0 OriginalGriff 275
1 DamithSL 265
2 CPallini 235
3 Maciej Los 185
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100