更新了一下,应该能算不同位数的减法了.MsgBox(0,0,jianfa(12361,580))
MsgBox(0,0,jianfa(100,1005))
MsgBox(0,0,jianfa("192.168.3.200","192.168.2.0",256, "."))
MsgBox(0,0,jianfa("6:30:54","20:45:12",60, ":"))
MsgBox(0,"16进制计算,aaaaa-ffff的值",jianfa("10:10:10:10:10","16:16:16:16",16,":"))
Func jianfa($x,$y,$o=10,$t="")
$a = StringSplit($x, $t)
$b = StringSplit($y, $t)
$p = ""
$q = ""
For $i = 1 To Abs($a[0]-$b[0])
If $a[0] < $b[0] Then $p = "0"&$t&$p
If $a[0] > $b[0] Then $q = "0"&$t&$q
Next
$x=$p&$x
$y=$q&$y
$a = StringSplit($x, $t)
$b = StringSplit($y, $t)
$txt = 0
For $i = 1 To $a[0]
$txt += ( $a[$i] - $b[$i] ) * ( $o ^ ( $a[0] - $i ) )
Next
Return $txt
EndFunc
|