有时候我们需要在vbs中输入的字符实现对齐效果,那么就可以参考下面的代码了
运行效果:
代码(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
2025国考·省考课程试听报名