有時候我們需要在vbs中輸入的字符實現(xiàn)對齊效果,那么就可以參考下面的代碼了
運行效果:
代碼(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