VBS小工具之计算子网掩码
mask.vbsDim mask,result,msg,canle,fail,temp,copyright
sorry = "对不起,您输入的掩码不合法!请输入0-24之间的某一整数!"
fail = "对不起,您输入的掩码长度超出了规定的范围!"
canle = "感谢您对Sian的关注,再会!"
msg = " 位掩码转换的结果为:"
copyright = "Copyright for Sian"
mask = Inputbox("请输入您需要计算的掩码长度!",copyright)
if IsEmpty(mask) then '用户选择退出
Msgbox canle,vbYes,copyright
else
if Isnumeric(mask) then '判断为数字输入,开始计算。
if mask<0 or mask>32 then '数字不属于0~24之间---Start
MsgBox fail,vbYes,copyright
else '计算开始
if mask>=0 and mask <8 then '计算第一个字节
mask = Cint(mask)
result = 256-2^(8-mask)
temp = Cstr(result)
Msgbox mask&(msg)&(temp)&".0.0.0",vbYes,copyright '输出
else
if mask >=8 and mask <16 then '计算第二个字节
mask = Cint(mask)
result = 256-2^(16-mask)
temp = Cstr(result)
Msgbox mask&(msg)+"255."+(temp)+".0.0",vbYes,copyright'输出
else
if mask >=16 and mask < 24 then '计算第三个字节
mask = Cint(mask)
result = 256-2^(24-mask)
temp = Cstr(result)
Msgbox mask&(msg)+"255.255."+(temp)+".0",vbYes,copyright '输出
else
if mask >=24 and mask <= 32 then '计算第四个字节
mask = Cint(mask)
result = 256-2^(32-mask)
temp = Cstr(result)
Msgbox mask&(msg)+"255.255.255."+(temp),vbYes,copyright '输出
else
end if
end if
end if
end if
end if '计算结束---End
else '一切非数字输入
Msgbox sorry,vbYes,copyright '输出非法
end if
end if
页:
[1]