« DOS Command Class for VBScript | Main | DropBox Freezes Out Explorer »

VBScript and Getting the Message Across

MsgBox MsgBoxIn preparing a post today I've been through a bit of a winding process whereby I came across an issue I'd never encountered before with a VBScript.  At first I thought I'd made some sort of mistake, but it appears I'd come across a limitation of a VBScript function I use all the time - MsgBox.

Echo EchoObviously the information is available in the VBScript documentation, but it seems rather vague:

The maximum length of prompt is approximately 1,024 characters, depending on the width of the characters used.

My tests have shown that it always seems to truncate at the 1,023rd character.

PopUp PopUpSo what's the alternative?  Well there are two WSH options.  The first is WScript.Echo which seems to have a huge limit of what it can display.  So much so that in testing I more than completely and successfully filled my screen with 92,160 characters using this function.  The second is more aligned to MsgBox and is the WshShell.PopUp method which has similar options to VBScript's message box.

An example script illustrating these options is given below.

Option Explicit

Dim strChunk
Dim strOut
Dim objWshShell
Dim intCount

Set objWshShell = WScript.CreateObject("WScript.Shell")
strChunk = ""
strOut = ""

'Build a chunk
For intCount = 1 to 1023
    strChunk = strChunk & "."

'Add a number to the end of a chunk and join 9 chunks together
For intCount = 1 to 9
    strOut = strOut & strChunk & intCount

'Display the total output in a message box
MsgBox strOut, vbInformation + vbOKOnly, "Message Box"

'Display the total output in a script echo
WScript.echo strOut

'Display the total output in a shell pop up
objWshShell.Popup strOut, 0, "Shell Popup", vbInformation

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>