转换PHP脚本以生成IP地址到VB.NET [英] Convert PHP script to generate IP Address to VB.NET

查看:49
本文介绍了转换PHP脚本以生成IP地址到VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是PHP脚本:

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 ++;
}
?>



这就是我在VB.NET2005中所做的



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



它应在192.168.255.255处停止,但应在192.168.3.2处停止.出了点问题,我无法理解.在VB.NET 2010中,该代码可以很好地与朋友提供的代码配合使用:



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


但是此代码在VB.NET 2005中不起作用.
你能帮我么 ?在此先感谢您和您花费很多时间来查看此问题.


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.

推荐答案

from = " 192.168.1.1";
from = "192.168.1.1";


至 = " ; // 生成IP地址
to = "192.169.255.255"; // generate ip addrs


arry1 = explode("


这篇关于转换PHP脚本以生成IP地址到VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆