Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - MsgBox Question

Reply
 
Old 04-19-2009   #1 (permalink)
Vgolfmaster


 
 

MsgBox Question

I have a script that is designed to be run using command line parameters
where the user enters a drive letter and a folder path. The script determines
if the entered drive exists and is ready, then determines if the folder
exists and wether or not it contains sub-folders. If it contains sub folders,
it prompts the user fto enter one of the sub folder, and then returns a list
of all files within the sub folder.

If the folder contains many files, I would like to limit the output (using a
MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's until all
output is displayed (if there are more than 20 files).

Does MsgBox have a built in trigger for this, where I can assign all the
output to a variable first and then have MsgBox handle this limit, or do I
somehow need to create a loop to collect 20 file names, show the MsgBox, and
then continue within the loop?

Here is the last portion of my script, in case anyone needs a better idea of
what I am trying to do. This shows all output in one MsgBox, and I want to
limit the MsgBox to 20 results, and use multiple MsgBox's for results of more
than 20.


'Check input folder for files and display results
set file = fso.GetFolder(string & "\" & input)
set files = file.files
if files.count <1 Then
WSCript.Echo "There are no files in this folder"
WSCript.Quit
End IF
for each f1 in files
flmsg = flmsg & f1.name
flmsg = flmsg & vbCrLf
next
MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg

--
"Friends Don''t Let Friends Dial-Up"

My System SpecsSystem Spec
Old 04-19-2009   #2 (permalink)
Alex K. Angelopoulos


 
 

Re: MsgBox Question

No, MsgBox doesn't have those capabilities. I've demoed a way to work around
this below, including dealing with a problem you may encounter; but there's
a bigger issue here in that this is not a very scalable way to write a
script. For some purposes, it won't matter - script is an ad-hoc solution -
but it may help to understand the context of the problem - what you're
trying to do in practical terms and who will be using the feedback how.

Anyway, here's some background, then a demo and some suggestions about what
else you might try. It's lengthy since I've been meaning to do a monologue
on MsgBox anyway.

MSGBOX PREHISTORY
The fundamental problem here is an awkward fact about MsgBox and its limits.
MsgBox was actually designed for one purpose and one purpose only originally
(meaning _before_ VBScript even existed). It was designed for graphical
applications with standard window output to easily display error messages or
ask a user for a very simple yes/no/cancel type of guidance when doing
something. It's simply not a very good mechanism for outputting arbitrarily
long sequences of information.

The dilemma here is that when VBScript first came out, it was really the
only easy tool for output, and when combined with InputBox it turned out
most basic scripts could get by with just those tools. As the only output
tool and one that also worked universally from any script host, it also was
the standard choice used for displaying output in the help files.

Now to the crux of the matter. In programming circles at least, it would be
considered "bad form" to use MsgBox. That's not directly relevant here
because we're using the tools at hand for dealing with the problem. I
personally _loathe_ using MsgBox for tasks like what you're trying to
accomplish, not because MsgBox is bad, but because in this role it's like
trying to use a large wrench as a hammer. However, in some cases the most
hammerlike thing in your toolbox is going to be a wrench.

SOLUTION TO LIMITING MSGBOX OUTPUT
You certainly CAN do the loop you're talking about, build a collection of 20
names and use them. I suspect you're using 20 as a rough rule of thumb
because more than 20 lines will run off the edge of the screen at lower
resolutions. However, there's another limit that you MIGHT encounter as
well; MsgBox is limited to 1023 characters of output, and you'll lose output
if you hit a specific sequence where names average over 50 characters in
length.
I've modified your code slightly and created a basic loop to buffer output
to MsgBox.
First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and in
MsgBox, vbLf displays just like vbCrLf would.
Next, I integrated a test that checks two things. One is whether the current
message contains more than 21 lines - the UBound() will show the upper bound
of the 0-based array that Split() returns, and including the initial header
line you use, when you have 20 files you'll have 21 lines. If you've hit
that maximum, the current message will be shown before the next name is
captured. The other check is the number of characters in the message; if the
current length plus the new name is greater than 1023 characters, then part
of a name will be cut off. There's one quirk here I'm using. I didn't count
the terminating vbLf we'll add to the next line because if it gets cut off I
don't care.
After the loop, if any file names remain, we need to dump the final files;
you'll see that after the end of the file loop.

the code:

header = "That Folder Contains the Following Files:" & vbLf
flmsg = header
' set to 1 less than display limit - allows for final vbLf
' NOTE - using vbLf; vbCrLf is TWO chars wide
' vbNewLine on Windows is also two chars wide; vbLf is cheaper
MaxFiles = 20
MaxMessageLength = 1022
for each f1 in files
nextname = f1.name
WScript.Echo nextname
if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
Len(flmsg) + Len(nextname) > 1023 then
' need to dump info before adding more
MsgBox flmsg
' reset to the header
flmsg = header
end if
flmsg = flmsg & nextname & vbLf
next
' if the message is more than just the header, we have more output.
if len(flmsg) > len(header) then
MsgBox flmsg
end if

WSCRIPT.ECHO, OR ...?
Depending on the context of how you're using this, there are potential
problems with using MsgBox. With very many files, it's tiresome to iterate
through them by continual mouse clicks. Presumably you're looking for
something, but you might blip past it, and of course you have no scrollback
since the MsgBox is gone.
Depending on the intent, you might consider using WScript.Echo. It doesn't
give you the ability to use a custom icon or display choices such as
yes/no/cancel, but it has two other advantages. WScript.Echo isn't limited
to 1023 characters of output; then you can use just 20 lines as your output
limit. If you run the script as a console script, you get streamed output
that requires no clicking and gives you scrollback; you can even redirect
the output to a file.
Other alternatives may exist, depending on what you want to do. If you're
just doing this as a specialized helper task for some specific problem and
the limits of MsgBox are OK for you, go ahead with your current approach. If
you're not sure, post back about what you're trying to do and what the
applied need is.


"Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
Quote:

> I have a script that is designed to be run using command line parameters
> where the user enters a drive letter and a folder path. The script
> determines
> if the entered drive exists and is ready, then determines if the folder
> exists and wether or not it contains sub-folders. If it contains sub
> folders,
> it prompts the user fto enter one of the sub folder, and then returns a
> list
> of all files within the sub folder.
>
> If the folder contains many files, I would like to limit the output (using
> a
> MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's until
> all
> output is displayed (if there are more than 20 files).
>
> Does MsgBox have a built in trigger for this, where I can assign all the
> output to a variable first and then have MsgBox handle this limit, or do I
> somehow need to create a loop to collect 20 file names, show the MsgBox,
> and
> then continue within the loop?
>
> Here is the last portion of my script, in case anyone needs a better idea
> of
> what I am trying to do. This shows all output in one MsgBox, and I want to
> limit the MsgBox to 20 results, and use multiple MsgBox's for results of
> more
> than 20.
>
>
> 'Check input folder for files and display results
> set file = fso.GetFolder(string & "\" & input)
> set files = file.files
> if files.count <1 Then
> WSCript.Echo "There are no files in this folder"
> WSCript.Quit
> End IF
> for each f1 in files
> flmsg = flmsg & f1.name
> flmsg = flmsg & vbCrLf
> next
> MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg
>
> --
> "Friends Don''t Let Friends Dial-Up"
My System SpecsSystem Spec
Old 04-19-2009   #3 (permalink)
Vgolfmaster


 
 

Re: MsgBox Question

Alex,

Thanks for the detailed response, very informative.

For this example, it is a requirement for me to use MsgBox. I will also add
that the character output restriction is not an issue for my purposes. I have
actually simply created a folder named 'test' on my 'C' drive, containint a
sub-folders named test1, test2, ect. Within these sub folders I have created
text files named text1, text2, ect. I wish to have one sub folder with more
than 20 text files, and have it list those text files in the MsgBox, but
limit it to 20 max at a time, requiring a second MsgBox for files 21-40, a
third for 41-60 ect.

This is not designed to be used in any real world application and will not
be deployed to search folders that might test the character limit. This is
actually a scripting assignment for me, and the MsgBox 20 line limit was
offered as extra credit, so I have to stay within the confines of MsgBox.

I was unsure if I could collect all the output (list of files) to the
variable first, and then configure the MsgBox to handle the 20 line
requirement, or if I needed to create a loop to collect 20 results, display
in a MsgBox, and then continue to the next 20 results. I have tried both ways
and continue to get ALL results listed in one MsgBox and am having a hard
time getting it to filter the results and lmit it to 20 per MsgBox.

Any suggestions you can offer for this lopop process would be greatly
appreciated!


--
"Friends Don''t Let Friends Dial-Up"


"Alex K. Angelopoulos" wrote:
Quote:

> No, MsgBox doesn't have those capabilities. I've demoed a way to work around
> this below, including dealing with a problem you may encounter; but there's
> a bigger issue here in that this is not a very scalable way to write a
> script. For some purposes, it won't matter - script is an ad-hoc solution -
> but it may help to understand the context of the problem - what you're
> trying to do in practical terms and who will be using the feedback how.
>
> Anyway, here's some background, then a demo and some suggestions about what
> else you might try. It's lengthy since I've been meaning to do a monologue
> on MsgBox anyway.
>
> MSGBOX PREHISTORY
> The fundamental problem here is an awkward fact about MsgBox and its limits.
> MsgBox was actually designed for one purpose and one purpose only originally
> (meaning _before_ VBScript even existed). It was designed for graphical
> applications with standard window output to easily display error messages or
> ask a user for a very simple yes/no/cancel type of guidance when doing
> something. It's simply not a very good mechanism for outputting arbitrarily
> long sequences of information.
>
> The dilemma here is that when VBScript first came out, it was really the
> only easy tool for output, and when combined with InputBox it turned out
> most basic scripts could get by with just those tools. As the only output
> tool and one that also worked universally from any script host, it also was
> the standard choice used for displaying output in the help files.
>
> Now to the crux of the matter. In programming circles at least, it would be
> considered "bad form" to use MsgBox. That's not directly relevant here
> because we're using the tools at hand for dealing with the problem. I
> personally _loathe_ using MsgBox for tasks like what you're trying to
> accomplish, not because MsgBox is bad, but because in this role it's like
> trying to use a large wrench as a hammer. However, in some cases the most
> hammerlike thing in your toolbox is going to be a wrench.
>
> SOLUTION TO LIMITING MSGBOX OUTPUT
> You certainly CAN do the loop you're talking about, build a collection of 20
> names and use them. I suspect you're using 20 as a rough rule of thumb
> because more than 20 lines will run off the edge of the screen at lower
> resolutions. However, there's another limit that you MIGHT encounter as
> well; MsgBox is limited to 1023 characters of output, and you'll lose output
> if you hit a specific sequence where names average over 50 characters in
> length.
> I've modified your code slightly and created a basic loop to buffer output
> to MsgBox.
> First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and in
> MsgBox, vbLf displays just like vbCrLf would.
> Next, I integrated a test that checks two things. One is whether the current
> message contains more than 21 lines - the UBound() will show the upper bound
> of the 0-based array that Split() returns, and including the initial header
> line you use, when you have 20 files you'll have 21 lines. If you've hit
> that maximum, the current message will be shown before the next name is
> captured. The other check is the number of characters in the message; if the
> current length plus the new name is greater than 1023 characters, then part
> of a name will be cut off. There's one quirk here I'm using. I didn't count
> the terminating vbLf we'll add to the next line because if it gets cut off I
> don't care.
> After the loop, if any file names remain, we need to dump the final files;
> you'll see that after the end of the file loop.
>
> the code:
>
> header = "That Folder Contains the Following Files:" & vbLf
> flmsg = header
> ' set to 1 less than display limit - allows for final vbLf
> ' NOTE - using vbLf; vbCrLf is TWO chars wide
> ' vbNewLine on Windows is also two chars wide; vbLf is cheaper
> MaxFiles = 20
> MaxMessageLength = 1022
> for each f1 in files
> nextname = f1.name
> WScript.Echo nextname
> if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
> Len(flmsg) + Len(nextname) > 1023 then
> ' need to dump info before adding more
> MsgBox flmsg
> ' reset to the header
> flmsg = header
> end if
> flmsg = flmsg & nextname & vbLf
> next
> ' if the message is more than just the header, we have more output.
> if len(flmsg) > len(header) then
> MsgBox flmsg
> end if
>
> WSCRIPT.ECHO, OR ...?
> Depending on the context of how you're using this, there are potential
> problems with using MsgBox. With very many files, it's tiresome to iterate
> through them by continual mouse clicks. Presumably you're looking for
> something, but you might blip past it, and of course you have no scrollback
> since the MsgBox is gone.
> Depending on the intent, you might consider using WScript.Echo. It doesn't
> give you the ability to use a custom icon or display choices such as
> yes/no/cancel, but it has two other advantages. WScript.Echo isn't limited
> to 1023 characters of output; then you can use just 20 lines as your output
> limit. If you run the script as a console script, you get streamed output
> that requires no clicking and gives you scrollback; you can even redirect
> the output to a file.
> Other alternatives may exist, depending on what you want to do. If you're
> just doing this as a specialized helper task for some specific problem and
> the limits of MsgBox are OK for you, go ahead with your current approach. If
> you're not sure, post back about what you're trying to do and what the
> applied need is.
>
>
> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
> news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
Quote:

> > I have a script that is designed to be run using command line parameters
> > where the user enters a drive letter and a folder path. The script
> > determines
> > if the entered drive exists and is ready, then determines if the folder
> > exists and wether or not it contains sub-folders. If it contains sub
> > folders,
> > it prompts the user fto enter one of the sub folder, and then returns a
> > list
> > of all files within the sub folder.
> >
> > If the folder contains many files, I would like to limit the output (using
> > a
> > MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's until
> > all
> > output is displayed (if there are more than 20 files).
> >
> > Does MsgBox have a built in trigger for this, where I can assign all the
> > output to a variable first and then have MsgBox handle this limit, or do I
> > somehow need to create a loop to collect 20 file names, show the MsgBox,
> > and
> > then continue within the loop?
> >
> > Here is the last portion of my script, in case anyone needs a better idea
> > of
> > what I am trying to do. This shows all output in one MsgBox, and I want to
> > limit the MsgBox to 20 results, and use multiple MsgBox's for results of
> > more
> > than 20.
> >
> >
> > 'Check input folder for files and display results
> > set file = fso.GetFolder(string & "\" & input)
> > set files = file.files
> > if files.count <1 Then
> > WSCript.Echo "There are no files in this folder"
> > WSCript.Quit
> > End IF
> > for each f1 in files
> > flmsg = flmsg & f1.name
> > flmsg = flmsg & vbCrLf
> > next
> > MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg
> >
> > --
> > "Friends Don''t Let Friends Dial-Up"
>
>
My System SpecsSystem Spec
Old 04-19-2009   #4 (permalink)
Alex K. Angelopoulos


 
 

Re: MsgBox Question

Well... here's my complete example code with the length limit chopped out,
and using vbCrLf.


dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
set folder = fso.GetFolder("C:\Windows")
set files = folder.files
header = "That Folder Contains the Following Files:" & vbCrLf
flmsg = header
for each f1 in files
nextname = f1.name
if ( UBound(Split(flmsg, vbCrLf)) > 20 ) Then
' need to dump info before adding more
MsgBox flmsg
' reset to the header
flmsg = header
end if
flmsg = flmsg & nextname & vbCrLf
next
' if the message is more than just the header, we have more output.
if len(flmsg) > len(header) then
MsgBox flmsg
end if

"Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
news:E0B91201-F094-4F02-8F9A-350143A5F778@xxxxxx
Quote:

> Alex,
>
> Thanks for the detailed response, very informative.
>
> For this example, it is a requirement for me to use MsgBox. I will also
> add
> that the character output restriction is not an issue for my purposes. I
> have
> actually simply created a folder named 'test' on my 'C' drive, containint
> a
> sub-folders named test1, test2, ect. Within these sub folders I have
> created
> text files named text1, text2, ect. I wish to have one sub folder with
> more
> than 20 text files, and have it list those text files in the MsgBox, but
> limit it to 20 max at a time, requiring a second MsgBox for files 21-40, a
> third for 41-60 ect.
>
> This is not designed to be used in any real world application and will not
> be deployed to search folders that might test the character limit. This is
> actually a scripting assignment for me, and the MsgBox 20 line limit was
> offered as extra credit, so I have to stay within the confines of MsgBox.
>
> I was unsure if I could collect all the output (list of files) to the
> variable first, and then configure the MsgBox to handle the 20 line
> requirement, or if I needed to create a loop to collect 20 results,
> display
> in a MsgBox, and then continue to the next 20 results. I have tried both
> ways
> and continue to get ALL results listed in one MsgBox and am having a hard
> time getting it to filter the results and lmit it to 20 per MsgBox.
>
> Any suggestions you can offer for this lopop process would be greatly
> appreciated!
>
>
> --
> "Friends Don''t Let Friends Dial-Up"
>
>
> "Alex K. Angelopoulos" wrote:
>
Quote:

>> No, MsgBox doesn't have those capabilities. I've demoed a way to work
>> around
>> this below, including dealing with a problem you may encounter; but
>> there's
>> a bigger issue here in that this is not a very scalable way to write a
>> script. For some purposes, it won't matter - script is an ad-hoc
>> solution -
>> but it may help to understand the context of the problem - what you're
>> trying to do in practical terms and who will be using the feedback how.
>>
>> Anyway, here's some background, then a demo and some suggestions about
>> what
>> else you might try. It's lengthy since I've been meaning to do a
>> monologue
>> on MsgBox anyway.
>>
>> MSGBOX PREHISTORY
>> The fundamental problem here is an awkward fact about MsgBox and its
>> limits.
>> MsgBox was actually designed for one purpose and one purpose only
>> originally
>> (meaning _before_ VBScript even existed). It was designed for graphical
>> applications with standard window output to easily display error messages
>> or
>> ask a user for a very simple yes/no/cancel type of guidance when doing
>> something. It's simply not a very good mechanism for outputting
>> arbitrarily
>> long sequences of information.
>>
>> The dilemma here is that when VBScript first came out, it was really the
>> only easy tool for output, and when combined with InputBox it turned out
>> most basic scripts could get by with just those tools. As the only output
>> tool and one that also worked universally from any script host, it also
>> was
>> the standard choice used for displaying output in the help files.
>>
>> Now to the crux of the matter. In programming circles at least, it would
>> be
>> considered "bad form" to use MsgBox. That's not directly relevant here
>> because we're using the tools at hand for dealing with the problem. I
>> personally _loathe_ using MsgBox for tasks like what you're trying to
>> accomplish, not because MsgBox is bad, but because in this role it's like
>> trying to use a large wrench as a hammer. However, in some cases the most
>> hammerlike thing in your toolbox is going to be a wrench.
>>
>> SOLUTION TO LIMITING MSGBOX OUTPUT
>> You certainly CAN do the loop you're talking about, build a collection of
>> 20
>> names and use them. I suspect you're using 20 as a rough rule of thumb
>> because more than 20 lines will run off the edge of the screen at lower
>> resolutions. However, there's another limit that you MIGHT encounter as
>> well; MsgBox is limited to 1023 characters of output, and you'll lose
>> output
>> if you hit a specific sequence where names average over 50 characters in
>> length.
>> I've modified your code slightly and created a basic loop to buffer
>> output
>> to MsgBox.
>> First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and in
>> MsgBox, vbLf displays just like vbCrLf would.
>> Next, I integrated a test that checks two things. One is whether the
>> current
>> message contains more than 21 lines - the UBound() will show the upper
>> bound
>> of the 0-based array that Split() returns, and including the initial
>> header
>> line you use, when you have 20 files you'll have 21 lines. If you've hit
>> that maximum, the current message will be shown before the next name is
>> captured. The other check is the number of characters in the message; if
>> the
>> current length plus the new name is greater than 1023 characters, then
>> part
>> of a name will be cut off. There's one quirk here I'm using. I didn't
>> count
>> the terminating vbLf we'll add to the next line because if it gets cut
>> off I
>> don't care.
>> After the loop, if any file names remain, we need to dump the final
>> files;
>> you'll see that after the end of the file loop.
>>
>> the code:
>>
>> header = "That Folder Contains the Following Files:" & vbLf
>> flmsg = header
>> ' set to 1 less than display limit - allows for final vbLf
>> ' NOTE - using vbLf; vbCrLf is TWO chars wide
>> ' vbNewLine on Windows is also two chars wide; vbLf is cheaper
>> MaxFiles = 20
>> MaxMessageLength = 1022
>> for each f1 in files
>> nextname = f1.name
>> WScript.Echo nextname
>> if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
>> Len(flmsg) + Len(nextname) > 1023 then
>> ' need to dump info before adding more
>> MsgBox flmsg
>> ' reset to the header
>> flmsg = header
>> end if
>> flmsg = flmsg & nextname & vbLf
>> next
>> ' if the message is more than just the header, we have more output.
>> if len(flmsg) > len(header) then
>> MsgBox flmsg
>> end if
>>
>> WSCRIPT.ECHO, OR ...?
>> Depending on the context of how you're using this, there are potential
>> problems with using MsgBox. With very many files, it's tiresome to
>> iterate
>> through them by continual mouse clicks. Presumably you're looking for
>> something, but you might blip past it, and of course you have no
>> scrollback
>> since the MsgBox is gone.
>> Depending on the intent, you might consider using WScript.Echo. It
>> doesn't
>> give you the ability to use a custom icon or display choices such as
>> yes/no/cancel, but it has two other advantages. WScript.Echo isn't
>> limited
>> to 1023 characters of output; then you can use just 20 lines as your
>> output
>> limit. If you run the script as a console script, you get streamed output
>> that requires no clicking and gives you scrollback; you can even redirect
>> the output to a file.
>> Other alternatives may exist, depending on what you want to do. If you're
>> just doing this as a specialized helper task for some specific problem
>> and
>> the limits of MsgBox are OK for you, go ahead with your current approach.
>> If
>> you're not sure, post back about what you're trying to do and what the
>> applied need is.
>>
>>
>> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
>> news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
Quote:

>> > I have a script that is designed to be run using command line
>> > parameters
>> > where the user enters a drive letter and a folder path. The script
>> > determines
>> > if the entered drive exists and is ready, then determines if the folder
>> > exists and wether or not it contains sub-folders. If it contains sub
>> > folders,
>> > it prompts the user fto enter one of the sub folder, and then returns a
>> > list
>> > of all files within the sub folder.
>> >
>> > If the folder contains many files, I would like to limit the output
>> > (using
>> > a
>> > MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's
>> > until
>> > all
>> > output is displayed (if there are more than 20 files).
>> >
>> > Does MsgBox have a built in trigger for this, where I can assign all
>> > the
>> > output to a variable first and then have MsgBox handle this limit, or
>> > do I
>> > somehow need to create a loop to collect 20 file names, show the
>> > MsgBox,
>> > and
>> > then continue within the loop?
>> >
>> > Here is the last portion of my script, in case anyone needs a better
>> > idea
>> > of
>> > what I am trying to do. This shows all output in one MsgBox, and I want
>> > to
>> > limit the MsgBox to 20 results, and use multiple MsgBox's for results
>> > of
>> > more
>> > than 20.
>> >
>> >
>> > 'Check input folder for files and display results
>> > set file = fso.GetFolder(string & "\" & input)
>> > set files = file.files
>> > if files.count <1 Then
>> > WSCript.Echo "There are no files in this folder"
>> > WSCript.Quit
>> > End IF
>> > for each f1 in files
>> > flmsg = flmsg & f1.name
>> > flmsg = flmsg & vbCrLf
>> > next
>> > MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg
>> >
>> > --
>> > "Friends Don''t Let Friends Dial-Up"
>>
>>
My System SpecsSystem Spec
Old 04-19-2009   #5 (permalink)
Vgolfmaster


 
 

Re: MsgBox Question

Alex,

Thanks again for the reply, but I am unfamiliar with the Ubound and Split
functions, and do not want to submit anything that i dont understand or can't
explain. I have tried other loops and lops within loops, all to no avail. It
just dawned on me that a variable for a counter might work, what do you think
of this:

for each f1 in files
flmsg = flmsg & f1.name
flmsg = flmsg & vbCrLf
count = count + 1
if count = 20 then MsgBox "That folder....." & flmsg
count = 0
Flmsg = ""
next
MsgBox "That folder......" & flmsg

Think that makes sense? if the counter hits 20 it pops up the MsgBox with
current 20 results, and resets the counter to 0 and and the message to blank,
and keeps going. If it never reaches 20 then finishes with the last MsgBox
line ?!?!

I know, poking and hoping here.......
--
"Friends Don''t Let Friends Dial-Up"


"Alex K. Angelopoulos" wrote:
Quote:

> Well... here's my complete example code with the length limit chopped out,
> and using vbCrLf.
>
>
> dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
> set folder = fso.GetFolder("C:\Windows")
> set files = folder.files
> header = "That Folder Contains the Following Files:" & vbCrLf
> flmsg = header
> for each f1 in files
> nextname = f1.name
> if ( UBound(Split(flmsg, vbCrLf)) > 20 ) Then
> ' need to dump info before adding more
> MsgBox flmsg
> ' reset to the header
> flmsg = header
> end if
> flmsg = flmsg & nextname & vbCrLf
> next
> ' if the message is more than just the header, we have more output.
> if len(flmsg) > len(header) then
> MsgBox flmsg
> end if
>
> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
> news:E0B91201-F094-4F02-8F9A-350143A5F778@xxxxxx
Quote:

> > Alex,
> >
> > Thanks for the detailed response, very informative.
> >
> > For this example, it is a requirement for me to use MsgBox. I will also
> > add
> > that the character output restriction is not an issue for my purposes. I
> > have
> > actually simply created a folder named 'test' on my 'C' drive, containint
> > a
> > sub-folders named test1, test2, ect. Within these sub folders I have
> > created
> > text files named text1, text2, ect. I wish to have one sub folder with
> > more
> > than 20 text files, and have it list those text files in the MsgBox, but
> > limit it to 20 max at a time, requiring a second MsgBox for files 21-40, a
> > third for 41-60 ect.
> >
> > This is not designed to be used in any real world application and will not
> > be deployed to search folders that might test the character limit. This is
> > actually a scripting assignment for me, and the MsgBox 20 line limit was
> > offered as extra credit, so I have to stay within the confines of MsgBox.
> >
> > I was unsure if I could collect all the output (list of files) to the
> > variable first, and then configure the MsgBox to handle the 20 line
> > requirement, or if I needed to create a loop to collect 20 results,
> > display
> > in a MsgBox, and then continue to the next 20 results. I have tried both
> > ways
> > and continue to get ALL results listed in one MsgBox and am having a hard
> > time getting it to filter the results and lmit it to 20 per MsgBox.
> >
> > Any suggestions you can offer for this lopop process would be greatly
> > appreciated!
> >
> >
> > --
> > "Friends Don''t Let Friends Dial-Up"
> >
> >
> > "Alex K. Angelopoulos" wrote:
> >
Quote:

> >> No, MsgBox doesn't have those capabilities. I've demoed a way to work
> >> around
> >> this below, including dealing with a problem you may encounter; but
> >> there's
> >> a bigger issue here in that this is not a very scalable way to write a
> >> script. For some purposes, it won't matter - script is an ad-hoc
> >> solution -
> >> but it may help to understand the context of the problem - what you're
> >> trying to do in practical terms and who will be using the feedback how.
> >>
> >> Anyway, here's some background, then a demo and some suggestions about
> >> what
> >> else you might try. It's lengthy since I've been meaning to do a
> >> monologue
> >> on MsgBox anyway.
> >>
> >> MSGBOX PREHISTORY
> >> The fundamental problem here is an awkward fact about MsgBox and its
> >> limits.
> >> MsgBox was actually designed for one purpose and one purpose only
> >> originally
> >> (meaning _before_ VBScript even existed). It was designed for graphical
> >> applications with standard window output to easily display error messages
> >> or
> >> ask a user for a very simple yes/no/cancel type of guidance when doing
> >> something. It's simply not a very good mechanism for outputting
> >> arbitrarily
> >> long sequences of information.
> >>
> >> The dilemma here is that when VBScript first came out, it was really the
> >> only easy tool for output, and when combined with InputBox it turned out
> >> most basic scripts could get by with just those tools. As the only output
> >> tool and one that also worked universally from any script host, it also
> >> was
> >> the standard choice used for displaying output in the help files.
> >>
> >> Now to the crux of the matter. In programming circles at least, it would
> >> be
> >> considered "bad form" to use MsgBox. That's not directly relevant here
> >> because we're using the tools at hand for dealing with the problem. I
> >> personally _loathe_ using MsgBox for tasks like what you're trying to
> >> accomplish, not because MsgBox is bad, but because in this role it's like
> >> trying to use a large wrench as a hammer. However, in some cases the most
> >> hammerlike thing in your toolbox is going to be a wrench.
> >>
> >> SOLUTION TO LIMITING MSGBOX OUTPUT
> >> You certainly CAN do the loop you're talking about, build a collection of
> >> 20
> >> names and use them. I suspect you're using 20 as a rough rule of thumb
> >> because more than 20 lines will run off the edge of the screen at lower
> >> resolutions. However, there's another limit that you MIGHT encounter as
> >> well; MsgBox is limited to 1023 characters of output, and you'll lose
> >> output
> >> if you hit a specific sequence where names average over 50 characters in
> >> length.
> >> I've modified your code slightly and created a basic loop to buffer
> >> output
> >> to MsgBox.
> >> First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and in
> >> MsgBox, vbLf displays just like vbCrLf would.
> >> Next, I integrated a test that checks two things. One is whether the
> >> current
> >> message contains more than 21 lines - the UBound() will show the upper
> >> bound
> >> of the 0-based array that Split() returns, and including the initial
> >> header
> >> line you use, when you have 20 files you'll have 21 lines. If you've hit
> >> that maximum, the current message will be shown before the next name is
> >> captured. The other check is the number of characters in the message; if
> >> the
> >> current length plus the new name is greater than 1023 characters, then
> >> part
> >> of a name will be cut off. There's one quirk here I'm using. I didn't
> >> count
> >> the terminating vbLf we'll add to the next line because if it gets cut
> >> off I
> >> don't care.
> >> After the loop, if any file names remain, we need to dump the final
> >> files;
> >> you'll see that after the end of the file loop.
> >>
> >> the code:
> >>
> >> header = "That Folder Contains the Following Files:" & vbLf
> >> flmsg = header
> >> ' set to 1 less than display limit - allows for final vbLf
> >> ' NOTE - using vbLf; vbCrLf is TWO chars wide
> >> ' vbNewLine on Windows is also two chars wide; vbLf is cheaper
> >> MaxFiles = 20
> >> MaxMessageLength = 1022
> >> for each f1 in files
> >> nextname = f1.name
> >> WScript.Echo nextname
> >> if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
> >> Len(flmsg) + Len(nextname) > 1023 then
> >> ' need to dump info before adding more
> >> MsgBox flmsg
> >> ' reset to the header
> >> flmsg = header
> >> end if
> >> flmsg = flmsg & nextname & vbLf
> >> next
> >> ' if the message is more than just the header, we have more output.
> >> if len(flmsg) > len(header) then
> >> MsgBox flmsg
> >> end if
> >>
> >> WSCRIPT.ECHO, OR ...?
> >> Depending on the context of how you're using this, there are potential
> >> problems with using MsgBox. With very many files, it's tiresome to
> >> iterate
> >> through them by continual mouse clicks. Presumably you're looking for
> >> something, but you might blip past it, and of course you have no
> >> scrollback
> >> since the MsgBox is gone.
> >> Depending on the intent, you might consider using WScript.Echo. It
> >> doesn't
> >> give you the ability to use a custom icon or display choices such as
> >> yes/no/cancel, but it has two other advantages. WScript.Echo isn't
> >> limited
> >> to 1023 characters of output; then you can use just 20 lines as your
> >> output
> >> limit. If you run the script as a console script, you get streamed output
> >> that requires no clicking and gives you scrollback; you can even redirect
> >> the output to a file.
> >> Other alternatives may exist, depending on what you want to do. If you're
> >> just doing this as a specialized helper task for some specific problem
> >> and
> >> the limits of MsgBox are OK for you, go ahead with your current approach.
> >> If
> >> you're not sure, post back about what you're trying to do and what the
> >> applied need is.
> >>
> >>
> >> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
> >> news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
> >> > I have a script that is designed to be run using command line
> >> > parameters
> >> > where the user enters a drive letter and a folder path. The script
> >> > determines
> >> > if the entered drive exists and is ready, then determines if the folder
> >> > exists and wether or not it contains sub-folders. If it contains sub
> >> > folders,
> >> > it prompts the user fto enter one of the sub folder, and then returns a
> >> > list
> >> > of all files within the sub folder.
> >> >
> >> > If the folder contains many files, I would like to limit the output
> >> > (using
> >> > a
> >> > MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's
> >> > until
> >> > all
> >> > output is displayed (if there are more than 20 files).
> >> >
> >> > Does MsgBox have a built in trigger for this, where I can assign all
> >> > the
> >> > output to a variable first and then have MsgBox handle this limit, or
> >> > do I
> >> > somehow need to create a loop to collect 20 file names, show the
> >> > MsgBox,
> >> > and
> >> > then continue within the loop?
> >> >
> >> > Here is the last portion of my script, in case anyone needs a better
> >> > idea
> >> > of
> >> > what I am trying to do. This shows all output in one MsgBox, and I want
> >> > to
> >> > limit the MsgBox to 20 results, and use multiple MsgBox's for results
> >> > of
> >> > more
> >> > than 20.
> >> >
> >> >
> >> > 'Check input folder for files and display results
> >> > set file = fso.GetFolder(string & "\" & input)
> >> > set files = file.files
> >> > if files.count <1 Then
> >> > WSCript.Echo "There are no files in this folder"
> >> > WSCript.Quit
> >> > End IF
> >> > for each f1 in files
> >> > flmsg = flmsg & f1.name
> >> > flmsg = flmsg & vbCrLf
> >> > next
> >> > MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg
> >> >
> >> > --
> >> > "Friends Don''t Let Friends Dial-Up"
> >>
> >>
>
My System SpecsSystem Spec
Old 04-20-2009   #6 (permalink)
Vgolfmaster


 
 

Re: MsgBox Question

Alex,

I finally got it!

This worked:

'Check input folder for files and display results
set file = fso.GetFolder(string & "\" & input)
set files = file.files
if files.count <1 Then
WSCript.Echo "There are no files in this folder"
WSCript.Quit
End IF
for each f1 in files
flmsg = flmsg & f1.name
flmsg = flmsg & vbCrLf
count = count + 1
If count = 20 Then
MsgBox "That Folder Contains The Following Files:" & vbCrLf &
flmsg
count = 0
flmsg= ""
End If
next
MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg

Thanks so much for the tips and great information, and your time!

--
"Friends Don''t Let Friends Dial-Up"


"Vgolfmaster" wrote:
Quote:

> Alex,
>
> Thanks again for the reply, but I am unfamiliar with the Ubound and Split
> functions, and do not want to submit anything that i dont understand or can't
> explain. I have tried other loops and lops within loops, all to no avail. It
> just dawned on me that a variable for a counter might work, what do you think
> of this:
>
> for each f1 in files
> flmsg = flmsg & f1.name
> flmsg = flmsg & vbCrLf
> count = count + 1
> if count = 20 then MsgBox "That folder....." & flmsg
> count = 0
> Flmsg = ""
> next
> MsgBox "That folder......" & flmsg
>
> Think that makes sense? if the counter hits 20 it pops up the MsgBox with
> current 20 results, and resets the counter to 0 and and the message to blank,
> and keeps going. If it never reaches 20 then finishes with the last MsgBox
> line ?!?!
>
> I know, poking and hoping here.......
> --
> "Friends Don''t Let Friends Dial-Up"
>
>
> "Alex K. Angelopoulos" wrote:
>
Quote:

> > Well... here's my complete example code with the length limit chopped out,
> > and using vbCrLf.
> >
> >
> > dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
> > set folder = fso.GetFolder("C:\Windows")
> > set files = folder.files
> > header = "That Folder Contains the Following Files:" & vbCrLf
> > flmsg = header
> > for each f1 in files
> > nextname = f1.name
> > if ( UBound(Split(flmsg, vbCrLf)) > 20 ) Then
> > ' need to dump info before adding more
> > MsgBox flmsg
> > ' reset to the header
> > flmsg = header
> > end if
> > flmsg = flmsg & nextname & vbCrLf
> > next
> > ' if the message is more than just the header, we have more output.
> > if len(flmsg) > len(header) then
> > MsgBox flmsg
> > end if
> >
> > "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
> > news:E0B91201-F094-4F02-8F9A-350143A5F778@xxxxxx
Quote:

> > > Alex,
> > >
> > > Thanks for the detailed response, very informative.
> > >
> > > For this example, it is a requirement for me to use MsgBox. I will also
> > > add
> > > that the character output restriction is not an issue for my purposes. I
> > > have
> > > actually simply created a folder named 'test' on my 'C' drive, containint
> > > a
> > > sub-folders named test1, test2, ect. Within these sub folders I have
> > > created
> > > text files named text1, text2, ect. I wish to have one sub folder with
> > > more
> > > than 20 text files, and have it list those text files in the MsgBox, but
> > > limit it to 20 max at a time, requiring a second MsgBox for files 21-40, a
> > > third for 41-60 ect.
> > >
> > > This is not designed to be used in any real world application and will not
> > > be deployed to search folders that might test the character limit. This is
> > > actually a scripting assignment for me, and the MsgBox 20 line limit was
> > > offered as extra credit, so I have to stay within the confines of MsgBox.
> > >
> > > I was unsure if I could collect all the output (list of files) to the
> > > variable first, and then configure the MsgBox to handle the 20 line
> > > requirement, or if I needed to create a loop to collect 20 results,
> > > display
> > > in a MsgBox, and then continue to the next 20 results. I have tried both
> > > ways
> > > and continue to get ALL results listed in one MsgBox and am having a hard
> > > time getting it to filter the results and lmit it to 20 per MsgBox.
> > >
> > > Any suggestions you can offer for this lopop process would be greatly
> > > appreciated!
> > >
> > >
> > > --
> > > "Friends Don''t Let Friends Dial-Up"
> > >
> > >
> > > "Alex K. Angelopoulos" wrote:
> > >
> > >> No, MsgBox doesn't have those capabilities. I've demoed a way to work
> > >> around
> > >> this below, including dealing with a problem you may encounter; but
> > >> there's
> > >> a bigger issue here in that this is not a very scalable way to write a
> > >> script. For some purposes, it won't matter - script is an ad-hoc
> > >> solution -
> > >> but it may help to understand the context of the problem - what you're
> > >> trying to do in practical terms and who will be using the feedback how.
> > >>
> > >> Anyway, here's some background, then a demo and some suggestions about
> > >> what
> > >> else you might try. It's lengthy since I've been meaning to do a
> > >> monologue
> > >> on MsgBox anyway.
> > >>
> > >> MSGBOX PREHISTORY
> > >> The fundamental problem here is an awkward fact about MsgBox and its
> > >> limits.
> > >> MsgBox was actually designed for one purpose and one purpose only
> > >> originally
> > >> (meaning _before_ VBScript even existed). It was designed for graphical
> > >> applications with standard window output to easily display error messages
> > >> or
> > >> ask a user for a very simple yes/no/cancel type of guidance when doing
> > >> something. It's simply not a very good mechanism for outputting
> > >> arbitrarily
> > >> long sequences of information.
> > >>
> > >> The dilemma here is that when VBScript first came out, it was really the
> > >> only easy tool for output, and when combined with InputBox it turned out
> > >> most basic scripts could get by with just those tools. As the only output
> > >> tool and one that also worked universally from any script host, it also
> > >> was
> > >> the standard choice used for displaying output in the help files.
> > >>
> > >> Now to the crux of the matter. In programming circles at least, it would
> > >> be
> > >> considered "bad form" to use MsgBox. That's not directly relevant here
> > >> because we're using the tools at hand for dealing with the problem. I
> > >> personally _loathe_ using MsgBox for tasks like what you're trying to
> > >> accomplish, not because MsgBox is bad, but because in this role it's like
> > >> trying to use a large wrench as a hammer. However, in some cases the most
> > >> hammerlike thing in your toolbox is going to be a wrench.
> > >>
> > >> SOLUTION TO LIMITING MSGBOX OUTPUT
> > >> You certainly CAN do the loop you're talking about, build a collection of
> > >> 20
> > >> names and use them. I suspect you're using 20 as a rough rule of thumb
> > >> because more than 20 lines will run off the edge of the screen at lower
> > >> resolutions. However, there's another limit that you MIGHT encounter as
> > >> well; MsgBox is limited to 1023 characters of output, and you'll lose
> > >> output
> > >> if you hit a specific sequence where names average over 50 characters in
> > >> length.
> > >> I've modified your code slightly and created a basic loop to buffer
> > >> output
> > >> to MsgBox.
> > >> First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and in
> > >> MsgBox, vbLf displays just like vbCrLf would.
> > >> Next, I integrated a test that checks two things. One is whether the
> > >> current
> > >> message contains more than 21 lines - the UBound() will show the upper
> > >> bound
> > >> of the 0-based array that Split() returns, and including the initial
> > >> header
> > >> line you use, when you have 20 files you'll have 21 lines. If you've hit
> > >> that maximum, the current message will be shown before the next name is
> > >> captured. The other check is the number of characters in the message; if
> > >> the
> > >> current length plus the new name is greater than 1023 characters, then
> > >> part
> > >> of a name will be cut off. There's one quirk here I'm using. I didn't
> > >> count
> > >> the terminating vbLf we'll add to the next line because if it gets cut
> > >> off I
> > >> don't care.
> > >> After the loop, if any file names remain, we need to dump the final
> > >> files;
> > >> you'll see that after the end of the file loop.
> > >>
> > >> the code:
> > >>
> > >> header = "That Folder Contains the Following Files:" & vbLf
> > >> flmsg = header
> > >> ' set to 1 less than display limit - allows for final vbLf
> > >> ' NOTE - using vbLf; vbCrLf is TWO chars wide
> > >> ' vbNewLine on Windows is also two chars wide; vbLf is cheaper
> > >> MaxFiles = 20
> > >> MaxMessageLength = 1022
> > >> for each f1 in files
> > >> nextname = f1.name
> > >> WScript.Echo nextname
> > >> if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
> > >> Len(flmsg) + Len(nextname) > 1023 then
> > >> ' need to dump info before adding more
> > >> MsgBox flmsg
> > >> ' reset to the header
> > >> flmsg = header
> > >> end if
> > >> flmsg = flmsg & nextname & vbLf
> > >> next
> > >> ' if the message is more than just the header, we have more output.
> > >> if len(flmsg) > len(header) then
> > >> MsgBox flmsg
> > >> end if
> > >>
> > >> WSCRIPT.ECHO, OR ...?
> > >> Depending on the context of how you're using this, there are potential
> > >> problems with using MsgBox. With very many files, it's tiresome to
> > >> iterate
> > >> through them by continual mouse clicks. Presumably you're looking for
> > >> something, but you might blip past it, and of course you have no
> > >> scrollback
> > >> since the MsgBox is gone.
> > >> Depending on the intent, you might consider using WScript.Echo. It
> > >> doesn't
> > >> give you the ability to use a custom icon or display choices such as
> > >> yes/no/cancel, but it has two other advantages. WScript.Echo isn't
> > >> limited
> > >> to 1023 characters of output; then you can use just 20 lines as your
> > >> output
> > >> limit. If you run the script as a console script, you get streamed output
> > >> that requires no clicking and gives you scrollback; you can even redirect
> > >> the output to a file.
> > >> Other alternatives may exist, depending on what you want to do. If you're
> > >> just doing this as a specialized helper task for some specific problem
> > >> and
> > >> the limits of MsgBox are OK for you, go ahead with your current approach.
> > >> If
> > >> you're not sure, post back about what you're trying to do and what the
> > >> applied need is.
> > >>
> > >>
> > >> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
> > >> news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
> > >> > I have a script that is designed to be run using command line
> > >> > parameters
> > >> > where the user enters a drive letter and a folder path. The script
> > >> > determines
> > >> > if the entered drive exists and is ready, then determines if the folder
> > >> > exists and wether or not it contains sub-folders. If it contains sub
> > >> > folders,
> > >> > it prompts the user fto enter one of the sub folder, and then returns a
> > >> > list
> > >> > of all files within the sub folder.
> > >> >
> > >> > If the folder contains many files, I would like to limit the output
> > >> > (using
> > >> > a
> > >> > MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's
> > >> > until
> > >> > all
> > >> > output is displayed (if there are more than 20 files).
> > >> >
> > >> > Does MsgBox have a built in trigger for this, where I can assign all
> > >> > the
> > >> > output to a variable first and then have MsgBox handle this limit, or
> > >> > do I
> > >> > somehow need to create a loop to collect 20 file names, show the
> > >> > MsgBox,
> > >> > and
> > >> > then continue within the loop?
> > >> >
> > >> > Here is the last portion of my script, in case anyone needs a better
> > >> > idea
> > >> > of
> > >> > what I am trying to do. This shows all output in one MsgBox, and I want
> > >> > to
> > >> > limit the MsgBox to 20 results, and use multiple MsgBox's for results
> > >> > of
> > >> > more
> > >> > than 20.
> > >> >
> > >> >
> > >> > 'Check input folder for files and display results
> > >> > set file = fso.GetFolder(string & "\" & input)
> > >> > set files = file.files
> > >> > if files.count <1 Then
> > >> > WSCript.Echo "There are no files in this folder"
> > >> > WSCript.Quit
> > >> > End IF
> > >> > for each f1 in files
> > >> > flmsg = flmsg & f1.name
> > >> > flmsg = flmsg & vbCrLf
> > >> > next
> > >> > MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg
> > >> >
> > >> > --
> > >> > "Friends Don''t Let Friends Dial-Up"
> > >>
> > >>
> >
My System SpecsSystem Spec
Old 04-20-2009   #7 (permalink)
Alex K. Angelopoulos


 
 

Re: MsgBox Question

Ironically, that's the one approach I didn't even think about - having an
embedded literal counter. ; )

"Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
news:2DD1D1BB-1FDE-4AD8-A8DC-586B28730F71@xxxxxx
Quote:

> Alex,
>
> I finally got it!
>
> This worked:
>
> 'Check input folder for files and display results
> set file = fso.GetFolder(string & "\" & input)
> set files = file.files
> if files.count <1 Then
> WSCript.Echo "There are no files in this folder"
> WSCript.Quit
> End IF
> for each f1 in files
> flmsg = flmsg & f1.name
> flmsg = flmsg & vbCrLf
> count = count + 1
> If count = 20 Then
> MsgBox "That Folder Contains The Following Files:" & vbCrLf &
> flmsg
> count = 0
> flmsg= ""
> End If
> next
> MsgBox "That Folder Contains The Following Files:" & vbCrLf & flmsg
>
> Thanks so much for the tips and great information, and your time!
>
> --
> "Friends Don''t Let Friends Dial-Up"
>
>
> "Vgolfmaster" wrote:
>
Quote:

>> Alex,
>>
>> Thanks again for the reply, but I am unfamiliar with the Ubound and Split
>> functions, and do not want to submit anything that i dont understand or
>> can't
>> explain. I have tried other loops and lops within loops, all to no avail.
>> It
>> just dawned on me that a variable for a counter might work, what do you
>> think
>> of this:
>>
>> for each f1 in files
>> flmsg = flmsg & f1.name
>> flmsg = flmsg & vbCrLf
>> count = count + 1
>> if count = 20 then MsgBox "That folder....." & flmsg
>> count = 0
>> Flmsg = ""
>> next
>> MsgBox "That folder......" & flmsg
>>
>> Think that makes sense? if the counter hits 20 it pops up the MsgBox with
>> current 20 results, and resets the counter to 0 and and the message to
>> blank,
>> and keeps going. If it never reaches 20 then finishes with the last
>> MsgBox
>> line ?!?!
>>
>> I know, poking and hoping here.......
>> --
>> "Friends Don''t Let Friends Dial-Up"
>>
>>
>> "Alex K. Angelopoulos" wrote:
>>
Quote:

>> > Well... here's my complete example code with the length limit chopped
>> > out,
>> > and using vbCrLf.
>> >
>> >
>> > dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
>> > set folder = fso.GetFolder("C:\Windows")
>> > set files = folder.files
>> > header = "That Folder Contains the Following Files:" & vbCrLf
>> > flmsg = header
>> > for each f1 in files
>> > nextname = f1.name
>> > if ( UBound(Split(flmsg, vbCrLf)) > 20 ) Then
>> > ' need to dump info before adding more
>> > MsgBox flmsg
>> > ' reset to the header
>> > flmsg = header
>> > end if
>> > flmsg = flmsg & nextname & vbCrLf
>> > next
>> > ' if the message is more than just the header, we have more output.
>> > if len(flmsg) > len(header) then
>> > MsgBox flmsg
>> > end if
>> >
>> > "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
>> > news:E0B91201-F094-4F02-8F9A-350143A5F778@xxxxxx
>> > > Alex,
>> > >
>> > > Thanks for the detailed response, very informative.
>> > >
>> > > For this example, it is a requirement for me to use MsgBox. I will
>> > > also
>> > > add
>> > > that the character output restriction is not an issue for my
>> > > purposes. I
>> > > have
>> > > actually simply created a folder named 'test' on my 'C' drive,
>> > > containint
>> > > a
>> > > sub-folders named test1, test2, ect. Within these sub folders I have
>> > > created
>> > > text files named text1, text2, ect. I wish to have one sub folder
>> > > with
>> > > more
>> > > than 20 text files, and have it list those text files in the MsgBox,
>> > > but
>> > > limit it to 20 max at a time, requiring a second MsgBox for files
>> > > 21-40, a
>> > > third for 41-60 ect.
>> > >
>> > > This is not designed to be used in any real world application and
>> > > will not
>> > > be deployed to search folders that might test the character limit.
>> > > This is
>> > > actually a scripting assignment for me, and the MsgBox 20 line limit
>> > > was
>> > > offered as extra credit, so I have to stay within the confines of
>> > > MsgBox.
>> > >
>> > > I was unsure if I could collect all the output (list of files) to the
>> > > variable first, and then configure the MsgBox to handle the 20 line
>> > > requirement, or if I needed to create a loop to collect 20 results,
>> > > display
>> > > in a MsgBox, and then continue to the next 20 results. I have tried
>> > > both
>> > > ways
>> > > and continue to get ALL results listed in one MsgBox and am having a
>> > > hard
>> > > time getting it to filter the results and lmit it to 20 per MsgBox.
>> > >
>> > > Any suggestions you can offer for this lopop process would be greatly
>> > > appreciated!
>> > >
>> > >
>> > > --
>> > > "Friends Don''t Let Friends Dial-Up"
>> > >
>> > >
>> > > "Alex K. Angelopoulos" wrote:
>> > >
>> > >> No, MsgBox doesn't have those capabilities. I've demoed a way to
>> > >> work
>> > >> around
>> > >> this below, including dealing with a problem you may encounter; but
>> > >> there's
>> > >> a bigger issue here in that this is not a very scalable way to write
>> > >> a
>> > >> script. For some purposes, it won't matter - script is an ad-hoc
>> > >> solution -
>> > >> but it may help to understand the context of the problem - what
>> > >> you're
>> > >> trying to do in practical terms and who will be using the feedback
>> > >> how.
>> > >>
>> > >> Anyway, here's some background, then a demo and some suggestions
>> > >> about
>> > >> what
>> > >> else you might try. It's lengthy since I've been meaning to do a
>> > >> monologue
>> > >> on MsgBox anyway.
>> > >>
>> > >> MSGBOX PREHISTORY
>> > >> The fundamental problem here is an awkward fact about MsgBox and its
>> > >> limits.
>> > >> MsgBox was actually designed for one purpose and one purpose only
>> > >> originally
>> > >> (meaning _before_ VBScript even existed). It was designed for
>> > >> graphical
>> > >> applications with standard window output to easily display error
>> > >> messages
>> > >> or
>> > >> ask a user for a very simple yes/no/cancel type of guidance when
>> > >> doing
>> > >> something. It's simply not a very good mechanism for outputting
>> > >> arbitrarily
>> > >> long sequences of information.
>> > >>
>> > >> The dilemma here is that when VBScript first came out, it was really
>> > >> the
>> > >> only easy tool for output, and when combined with InputBox it turned
>> > >> out
>> > >> most basic scripts could get by with just those tools. As the only
>> > >> output
>> > >> tool and one that also worked universally from any script host, it
>> > >> also
>> > >> was
>> > >> the standard choice used for displaying output in the help files.
>> > >>
>> > >> Now to the crux of the matter. In programming circles at least, it
>> > >> would
>> > >> be
>> > >> considered "bad form" to use MsgBox. That's not directly relevant
>> > >> here
>> > >> because we're using the tools at hand for dealing with the problem.
>> > >> I
>> > >> personally _loathe_ using MsgBox for tasks like what you're trying
>> > >> to
>> > >> accomplish, not because MsgBox is bad, but because in this role it's
>> > >> like
>> > >> trying to use a large wrench as a hammer. However, in some cases the
>> > >> most
>> > >> hammerlike thing in your toolbox is going to be a wrench.
>> > >>
>> > >> SOLUTION TO LIMITING MSGBOX OUTPUT
>> > >> You certainly CAN do the loop you're talking about, build a
>> > >> collection of
>> > >> 20
>> > >> names and use them. I suspect you're using 20 as a rough rule of
>> > >> thumb
>> > >> because more than 20 lines will run off the edge of the screen at
>> > >> lower
>> > >> resolutions. However, there's another limit that you MIGHT encounter
>> > >> as
>> > >> well; MsgBox is limited to 1023 characters of output, and you'll
>> > >> lose
>> > >> output
>> > >> if you hit a specific sequence where names average over 50
>> > >> characters in
>> > >> length.
>> > >> I've modified your code slightly and created a basic loop to buffer
>> > >> output
>> > >> to MsgBox.
>> > >> First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and
>> > >> in
>> > >> MsgBox, vbLf displays just like vbCrLf would.
>> > >> Next, I integrated a test that checks two things. One is whether the
>> > >> current
>> > >> message contains more than 21 lines - the UBound() will show the
>> > >> upper
>> > >> bound
>> > >> of the 0-based array that Split() returns, and including the initial
>> > >> header
>> > >> line you use, when you have 20 files you'll have 21 lines. If you've
>> > >> hit
>> > >> that maximum, the current message will be shown before the next name
>> > >> is
>> > >> captured. The other check is the number of characters in the
>> > >> message; if
>> > >> the
>> > >> current length plus the new name is greater than 1023 characters,
>> > >> then
>> > >> part
>> > >> of a name will be cut off. There's one quirk here I'm using. I
>> > >> didn't
>> > >> count
>> > >> the terminating vbLf we'll add to the next line because if it gets
>> > >> cut
>> > >> off I
>> > >> don't care.
>> > >> After the loop, if any file names remain, we need to dump the final
>> > >> files;
>> > >> you'll see that after the end of the file loop.
>> > >>
>> > >> the code:
>> > >>
>> > >> header = "That Folder Contains the Following Files:" & vbLf
>> > >> flmsg = header
>> > >> ' set to 1 less than display limit - allows for final vbLf
>> > >> ' NOTE - using vbLf; vbCrLf is TWO chars wide
>> > >> ' vbNewLine on Windows is also two chars wide; vbLf is cheaper
>> > >> MaxFiles = 20
>> > >> MaxMessageLength = 1022
>> > >> for each f1 in files
>> > >> nextname = f1.name
>> > >> WScript.Echo nextname
>> > >> if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
>> > >> Len(flmsg) + Len(nextname) > 1023 then
>> > >> ' need to dump info before adding more
>> > >> MsgBox flmsg
>> > >> ' reset to the header
>> > >> flmsg = header
>> > >> end if
>> > >> flmsg = flmsg & nextname & vbLf
>> > >> next
>> > >> ' if the message is more than just the header, we have more output.
>> > >> if len(flmsg) > len(header) then
>> > >> MsgBox flmsg
>> > >> end if
>> > >>
>> > >> WSCRIPT.ECHO, OR ...?
>> > >> Depending on the context of how you're using this, there are
>> > >> potential
>> > >> problems with using MsgBox. With very many files, it's tiresome to
>> > >> iterate
>> > >> through them by continual mouse clicks. Presumably you're looking
>> > >> for
>> > >> something, but you might blip past it, and of course you have no
>> > >> scrollback
>> > >> since the MsgBox is gone.
>> > >> Depending on the intent, you might consider using WScript.Echo. It
>> > >> doesn't
>> > >> give you the ability to use a custom icon or display choices such as
>> > >> yes/no/cancel, but it has two other advantages. WScript.Echo isn't
>> > >> limited
>> > >> to 1023 characters of output; then you can use just 20 lines as your
>> > >> output
>> > >> limit. If you run the script as a console script, you get streamed
>> > >> output
>> > >> that requires no clicking and gives you scrollback; you can even
>> > >> redirect
>> > >> the output to a file.
>> > >> Other alternatives may exist, depending on what you want to do. If
>> > >> you're
>> > >> just doing this as a specialized helper task for some specific
>> > >> problem
>> > >> and
>> > >> the limits of MsgBox are OK for you, go ahead with your current
>> > >> approach.
>> > >> If
>> > >> you're not sure, post back about what you're trying to do and what
>> > >> the
>> > >> applied need is.
>> > >>
>> > >>
>> > >> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in
>> > >> message
>> > >> news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
>> > >> > I have a script that is designed to be run using command line
>> > >> > parameters
>> > >> > where the user enters a drive letter and a folder path. The script
>> > >> > determines
>> > >> > if the entered drive exists and is ready, then determines if the
>> > >> > folder
>> > >> > exists and wether or not it contains sub-folders. If it contains
>> > >> > sub
>> > >> > folders,
>> > >> > it prompts the user fto enter one of the sub folder, and then
>> > >> > returns a
>> > >> > list
>> > >> > of all files within the sub folder.
>> > >> >
>> > >> > If the folder contains many files, I would like to limit the
>> > >> > output
>> > >> > (using
>> > >> > a
>> > >> > MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's
>> > >> > until
>> > >> > all
>> > >> > output is displayed (if there are more than 20 files).
>> > >> >
>> > >> > Does MsgBox have a built in trigger for this, where I can assign
>> > >> > all
>> > >> > the
>> > >> > output to a variable first and then have MsgBox handle this limit,
>> > >> > or
>> > >> > do I
>> > >> > somehow need to create a loop to collect 20 file names, show the
>> > >> > MsgBox,
>> > >> > and
>> > >> > then continue within the loop?
>> > >> >
>> > >> > Here is the last portion of my script, in case anyone needs a
>> > >> > better
>> > >> > idea
>> > >> > of
>> > >> > what I am trying to do. This shows all output in one MsgBox, and I
>> > >> > want
>> > >> > to
>> > >> > limit the MsgBox to 20 results, and use multiple MsgBox's for
>> > >> > results
>> > >> > of
>> > >> > more
>> > >> > than 20.
>> > >> >
>> > >> >
>> > >> > 'Check input folder for files and display results
>> > >> > set file = fso.GetFolder(string & "\" & input)
>> > >> > set files = file.files
>> > >> > if files.count <1 Then
>> > >> > WSCript.Echo "There are no files in this folder"
>> > >> > WSCript.Quit
>> > >> > End IF
>> > >> > for each f1 in files
>> > >> > flmsg = flmsg & f1.name
>> > >> > flmsg = flmsg & vbCrLf
>> > >> > next
>> > >> > MsgBox "That Folder Contains The Following Files:" & vbCrLf &
>> > >> > flmsg
>> > >> >
>> > >> > --
>> > >> > "Friends Don''t Let Friends Dial-Up"
>> > >>
>> > >>
>> >
My System SpecsSystem Spec
Old 04-20-2009   #8 (permalink)
Al Dunbar


 
 

Re: MsgBox Question


"Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
news:22BE0814-495A-4921-8505-F05821B61538@xxxxxx
Quote:

> Alex,
>
> Thanks again for the reply, but I am unfamiliar with the Ubound and Split
> functions, and do not want to submit anything that i dont understand or
> can't
> explain.
Fair enough. But when I went to school we were also expected to do our own
homework.

/Al
Quote:

> I have tried other loops and lops within loops, all to no avail. It
> just dawned on me that a variable for a counter might work, what do you
> think
> of this:
>
> for each f1 in files
> flmsg = flmsg & f1.name
> flmsg = flmsg & vbCrLf
> count = count + 1
> if count = 20 then MsgBox "That folder....." & flmsg
> count = 0
> Flmsg = ""
> next
> MsgBox "That folder......" & flmsg
>
> Think that makes sense? if the counter hits 20 it pops up the MsgBox with
> current 20 results, and resets the counter to 0 and and the message to
> blank,
> and keeps going. If it never reaches 20 then finishes with the last MsgBox
> line ?!?!
>
> I know, poking and hoping here.......
> --
> "Friends Don''t Let Friends Dial-Up"
>
>
> "Alex K. Angelopoulos" wrote:
>
Quote:

>> Well... here's my complete example code with the length limit chopped
>> out,
>> and using vbCrLf.
>>
>>
>> dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
>> set folder = fso.GetFolder("C:\Windows")
>> set files = folder.files
>> header = "That Folder Contains the Following Files:" & vbCrLf
>> flmsg = header
>> for each f1 in files
>> nextname = f1.name
>> if ( UBound(Split(flmsg, vbCrLf)) > 20 ) Then
>> ' need to dump info before adding more
>> MsgBox flmsg
>> ' reset to the header
>> flmsg = header
>> end if
>> flmsg = flmsg & nextname & vbCrLf
>> next
>> ' if the message is more than just the header, we have more output.
>> if len(flmsg) > len(header) then
>> MsgBox flmsg
>> end if
>>
>> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
>> news:E0B91201-F094-4F02-8F9A-350143A5F778@xxxxxx
Quote:

>> > Alex,
>> >
>> > Thanks for the detailed response, very informative.
>> >
>> > For this example, it is a requirement for me to use MsgBox. I will also
>> > add
>> > that the character output restriction is not an issue for my purposes.
>> > I
>> > have
>> > actually simply created a folder named 'test' on my 'C' drive,
>> > containint
>> > a
>> > sub-folders named test1, test2, ect. Within these sub folders I have
>> > created
>> > text files named text1, text2, ect. I wish to have one sub folder with
>> > more
>> > than 20 text files, and have it list those text files in the MsgBox,
>> > but
>> > limit it to 20 max at a time, requiring a second MsgBox for files
>> > 21-40, a
>> > third for 41-60 ect.
>> >
>> > This is not designed to be used in any real world application and will
>> > not
>> > be deployed to search folders that might test the character limit. This
>> > is
>> > actually a scripting assignment for me, and the MsgBox 20 line limit
>> > was
>> > offered as extra credit, so I have to stay within the confines of
>> > MsgBox.
>> >
>> > I was unsure if I could collect all the output (list of files) to the
>> > variable first, and then configure the MsgBox to handle the 20 line
>> > requirement, or if I needed to create a loop to collect 20 results,
>> > display
>> > in a MsgBox, and then continue to the next 20 results. I have tried
>> > both
>> > ways
>> > and continue to get ALL results listed in one MsgBox and am having a
>> > hard
>> > time getting it to filter the results and lmit it to 20 per MsgBox.
>> >
>> > Any suggestions you can offer for this lopop process would be greatly
>> > appreciated!
>> >
>> >
>> > --
>> > "Friends Don''t Let Friends Dial-Up"
>> >
>> >
>> > "Alex K. Angelopoulos" wrote:
>> >
>> >> No, MsgBox doesn't have those capabilities. I've demoed a way to work
>> >> around
>> >> this below, including dealing with a problem you may encounter; but
>> >> there's
>> >> a bigger issue here in that this is not a very scalable way to write a
>> >> script. For some purposes, it won't matter - script is an ad-hoc
>> >> solution -
>> >> but it may help to understand the context of the problem - what you're
>> >> trying to do in practical terms and who will be using the feedback
>> >> how.
>> >>
>> >> Anyway, here's some background, then a demo and some suggestions about
>> >> what
>> >> else you might try. It's lengthy since I've been meaning to do a
>> >> monologue
>> >> on MsgBox anyway.
>> >>
>> >> MSGBOX PREHISTORY
>> >> The fundamental problem here is an awkward fact about MsgBox and its
>> >> limits.
>> >> MsgBox was actually designed for one purpose and one purpose only
>> >> originally
>> >> (meaning _before_ VBScript even existed). It was designed for
>> >> graphical
>> >> applications with standard window output to easily display error
>> >> messages
>> >> or
>> >> ask a user for a very simple yes/no/cancel type of guidance when doing
>> >> something. It's simply not a very good mechanism for outputting
>> >> arbitrarily
>> >> long sequences of information.
>> >>
>> >> The dilemma here is that when VBScript first came out, it was really
>> >> the
>> >> only easy tool for output, and when combined with InputBox it turned
>> >> out
>> >> most basic scripts could get by with just those tools. As the only
>> >> output
>> >> tool and one that also worked universally from any script host, it
>> >> also
>> >> was
>> >> the standard choice used for displaying output in the help files.
>> >>
>> >> Now to the crux of the matter. In programming circles at least, it
>> >> would
>> >> be
>> >> considered "bad form" to use MsgBox. That's not directly relevant here
>> >> because we're using the tools at hand for dealing with the problem. I
>> >> personally _loathe_ using MsgBox for tasks like what you're trying to
>> >> accomplish, not because MsgBox is bad, but because in this role it's
>> >> like
>> >> trying to use a large wrench as a hammer. However, in some cases the
>> >> most
>> >> hammerlike thing in your toolbox is going to be a wrench.
>> >>
>> >> SOLUTION TO LIMITING MSGBOX OUTPUT
>> >> You certainly CAN do the loop you're talking about, build a collection
>> >> of
>> >> 20
>> >> names and use them. I suspect you're using 20 as a rough rule of thumb
>> >> because more than 20 lines will run off the edge of the screen at
>> >> lower
>> >> resolutions. However, there's another limit that you MIGHT encounter
>> >> as
>> >> well; MsgBox is limited to 1023 characters of output, and you'll lose
>> >> output
>> >> if you hit a specific sequence where names average over 50 characters
>> >> in
>> >> length.
>> >> I've modified your code slightly and created a basic loop to buffer
>> >> output
>> >> to MsgBox.
>> >> First, I changed vbCrLf to vbLf; vbCrLf is a 2 character value and in
>> >> MsgBox, vbLf displays just like vbCrLf would.
>> >> Next, I integrated a test that checks two things. One is whether the
>> >> current
>> >> message contains more than 21 lines - the UBound() will show the upper
>> >> bound
>> >> of the 0-based array that Split() returns, and including the initial
>> >> header
>> >> line you use, when you have 20 files you'll have 21 lines. If you've
>> >> hit
>> >> that maximum, the current message will be shown before the next name
>> >> is
>> >> captured. The other check is the number of characters in the message;
>> >> if
>> >> the
>> >> current length plus the new name is greater than 1023 characters, then
>> >> part
>> >> of a name will be cut off. There's one quirk here I'm using. I didn't
>> >> count
>> >> the terminating vbLf we'll add to the next line because if it gets cut
>> >> off I
>> >> don't care.
>> >> After the loop, if any file names remain, we need to dump the final
>> >> files;
>> >> you'll see that after the end of the file loop.
>> >>
>> >> the code:
>> >>
>> >> header = "That Folder Contains the Following Files:" & vbLf
>> >> flmsg = header
>> >> ' set to 1 less than display limit - allows for final vbLf
>> >> ' NOTE - using vbLf; vbCrLf is TWO chars wide
>> >> ' vbNewLine on Windows is also two chars wide; vbLf is cheaper
>> >> MaxFiles = 20
>> >> MaxMessageLength = 1022
>> >> for each f1 in files
>> >> nextname = f1.name
>> >> WScript.Echo nextname
>> >> if ( UBound(Split(flmsg, vbLf)) > 20 ) OR _
>> >> Len(flmsg) + Len(nextname) > 1023 then
>> >> ' need to dump info before adding more
>> >> MsgBox flmsg
>> >> ' reset to the header
>> >> flmsg = header
>> >> end if
>> >> flmsg = flmsg & nextname & vbLf
>> >> next
>> >> ' if the message is more than just the header, we have more output.
>> >> if len(flmsg) > len(header) then
>> >> MsgBox flmsg
>> >> end if
>> >>
>> >> WSCRIPT.ECHO, OR ...?
>> >> Depending on the context of how you're using this, there are potential
>> >> problems with using MsgBox. With very many files, it's tiresome to
>> >> iterate
>> >> through them by continual mouse clicks. Presumably you're looking for
>> >> something, but you might blip past it, and of course you have no
>> >> scrollback
>> >> since the MsgBox is gone.
>> >> Depending on the intent, you might consider using WScript.Echo. It
>> >> doesn't
>> >> give you the ability to use a custom icon or display choices such as
>> >> yes/no/cancel, but it has two other advantages. WScript.Echo isn't
>> >> limited
>> >> to 1023 characters of output; then you can use just 20 lines as your
>> >> output
>> >> limit. If you run the script as a console script, you get streamed
>> >> output
>> >> that requires no clicking and gives you scrollback; you can even
>> >> redirect
>> >> the output to a file.
>> >> Other alternatives may exist, depending on what you want to do. If
>> >> you're
>> >> just doing this as a specialized helper task for some specific problem
>> >> and
>> >> the limits of MsgBox are OK for you, go ahead with your current
>> >> approach.
>> >> If
>> >> you're not sure, post back about what you're trying to do and what the
>> >> applied need is.
>> >>
>> >>
>> >> "Vgolfmaster" <Vgolfmaster@xxxxxx> wrote in message
>> >> news:CE08A93F-253D-4DF0-9F54-676C3ACDF317@xxxxxx
>> >> > I have a script that is designed to be run using command line
>> >> > parameters
>> >> > where the user enters a drive letter and a folder path. The script
>> >> > determines
>> >> > if the entered drive exists and is ready, then determines if the
>> >> > folder
>> >> > exists and wether or not it contains sub-folders. If it contains sub
>> >> > folders,
>> >> > it prompts the user fto enter one of the sub folder, and then
>> >> > returns a
>> >> > list
>> >> > of all files within the sub folder.
>> >> >
>> >> > If the folder contains many files, I would like to limit the output
>> >> > (using
>> >> > a
>> >> > MsgBox) to 20 entries for each MsgBox, and force multiple MsgBox's
>> >> > until
>> >> > all
>> >> > output is displayed (if there are more than 20 files).
>> >> >
>> >> > Does MsgBox have a built in trigger for this, where I can assign all
>> >> > the
>> >> > output to a variable first and then have MsgBox handle this limit,
>> >> > or
>> >> > do I
>> >> > somehow need to create a loop to collect 20 file names, show the
>> >> > MsgBox,
>> >> > and
>> >> > then continue within the loop?
>> >> >
>> >> > Here is the last portion of my script, in case anyone needs a better
>> >> > idea
>> >> > of
>> >> > what I am trying to do. This shows all output in one MsgBox, and I
>> >> > want
>> >> > to
>> >> > limit the MsgBox to 20 results, and use multiple MsgBox's for
>> >> > results
>> >> > of
>> >> > more
>> >> > than 20.
>> >> >
>> >> >
>> >> > 'Check input folder for files and display results
>> >> > set file = fso.GetFolder(string & "\" & input)
>> >> > set files = file.files
>> >> > if files.count <1 Then
>> >> > WSCript.Echo "There are no files in this folder"
>> >> > WSCript.Quit
>> >> > End IF
>> >> > for each f1 in files
>> >> > flmsg = flmsg & f1.name
>> >> > flmsg = flmsg & vbCrLf
>> >> > next
>> >> > MsgBox "That Folder Contains The Following Files:" & vbCrLf &
>> >> > flmsg
>> >> >
>> >> > --
>> >> > "Friends Don''t Let Friends Dial-Up"
>> >>
>> >>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
MsgBox "Hi", 6858 VB Script
MsgBox help needed VB Script
Script to launch a MSGBOX listing PST file locations for a logged onuser VB Script
Dual boot system question and family deal discount question Vista General
Using msgbox PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46