Vbscript 如何在msgbox中输出超过最大字符限制的字符?

Vbscript 如何在msgbox中输出超过最大字符限制的字符?,vbscript,Vbscript,我需要在msgbox中向用户显示一条相当长的消息。然而,在某些情况下,msgbox似乎达到了它的字符限制。这个问题的解决方案是什么?我使用objShell.Popup来实现这一点 Set objShell = CreateObject("Wscript.Shell") objShell.Popup messagehere 使用Wscript.Echo消息 而不是MsgBox消息 其中,b是一个变量,其中包含您需要在messagebox中显示的所有内容。以下是一种绕过1023字符限制的方

我需要在msgbox中向用户显示一条相当长的消息。然而,在某些情况下,msgbox似乎达到了它的字符限制。这个问题的解决方案是什么?

我使用objShell.Popup来实现这一点

Set objShell = CreateObject("Wscript.Shell")
    objShell.Popup messagehere
使用Wscript.Echo消息 而不是MsgBox消息


其中,b是一个变量,其中包含您需要在messagebox中显示的所有内容。

以下是一种绕过1023字符限制的方法:

Sub testWSHEnvironment()
    Dim WshShell  As IWshRuntimeLibrary.WshShell, WshSysEnv  As _
        CIWshRuntimeLibrary.WshEnvironment
    Set WshShell = CreateObject("WScript.Shell")
    Set WshSysEnv = WshShell.Environment("SYSTEM")
    theList = "Environmental Variables:"
    theCount = 0
    For Each thisItem In WshSysEnv
        If (Len(theList) + Len(CStr(theCount)) + 4 + Len(thisItem) > 1023) Then
            MsgBox theList
            theList = "More Variables:"
        End If
        theCount = theCount + 1
        theList = theList & vbCrLf & theCount & ": " & thisItem
    Next thisItem
    MsgBox theList
End Sub

这将生成尽可能多的MsgBox弹出窗口,以显示环境变量列表。请注意,您需要在总和中包含4,以便考虑列表中每个项目的vbCrLf=careerReturn/LineFeed和“:”。

不要忘记将objShell作为对象进行调暗
Sub testWSHEnvironment()
    Dim WshShell  As IWshRuntimeLibrary.WshShell, WshSysEnv  As _
        CIWshRuntimeLibrary.WshEnvironment
    Set WshShell = CreateObject("WScript.Shell")
    Set WshSysEnv = WshShell.Environment("SYSTEM")
    theList = "Environmental Variables:"
    theCount = 0
    For Each thisItem In WshSysEnv
        If (Len(theList) + Len(CStr(theCount)) + 4 + Len(thisItem) > 1023) Then
            MsgBox theList
            theList = "More Variables:"
        End If
        theCount = theCount + 1
        theList = theList & vbCrLf & theCount & ": " & thisItem
    Next thisItem
    MsgBox theList
End Sub