VBScript 输出中的对齐实现方法
程序员文章站
2022-07-06 12:58:42
运行效果:
代码(foutput.vbs):
复制代码 代码如下:strcomputer = "." set objwmiservice = getobject("wi...
运行效果:
strcomputer = "."
set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2")
set colitems = objwmiservice.execquery( _
"select * from win32_networkadapterconfiguration",,48)
for each objitem in colitems
wscript.echo objitem.caption & foutput(objitem.caption) & "textinfo"
next
原文:https://www.enun.net/?p=2381
代码(foutput.vbs):
复制代码 代码如下:
strcomputer = "."
set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2")
set colitems = objwmiservice.execquery( _
"select * from win32_networkadapterconfiguration",,48)
for each objitem in colitems
wscript.echo objitem.caption & foutput(objitem.caption) & "textinfo"
next
function foutput(strname)
strlen = len(strname)
select case true
case strlen < 8
foutput = chr(9) & chr(9) & chr(9) & chr(9) & chr(9)
case strlen < 16
foutput = chr(9) & chr(9) & chr(9) & chr(9)
case strlen < 24
foutput = chr(9) & chr(9) & chr(9)
case strlen < 32
foutput = chr(9) & chr(9)
case strlen < 40
foutput = chr(9)
case else
'超过40的只取前32位
for k = 1 to strlen - 32
foutput = foutput & chr(8)
next
foutput = foutput & " ..." & chr(9)
end select
end function
原文:https://www.enun.net/?p=2381