VBScript如何实现输出中的对齐

这篇文章主要介绍了VBScript如何实现输出中的对齐,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

运行效果:

VBScript如何实现输出中的对齐

代码(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

感谢你能够认真阅读完这篇文章,希望小编分享的“VBScript如何实现输出中的对齐”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注行业资讯频道,更多相关知识等着你来学习!