Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Popup Msgbox not working... HELP!

1,030 views
Skip to first unread message

Steve Blake

unread,
Apr 26, 2013, 1:59:22 PM4/26/13
to
Okay, this should be a no brainer but I am have an issue with the following code working.
'################## DOES NOT WORK ########################

sub DisplayMessage(message)
Mresponse = ws.Popup (message, 30, "Information:", 1)
if (Mresponse = 2) then
msgbox "cancelled selected. Will now quit."
wscript.quit
elseif (Mresponse = -1) then
msgbox "Timed out. Will now quit."
wscript.quit
end if
msgbox "continuing to run"
end sub

'################## DOES WORK ########################

sub DisplayMessage(message)
if (ws.Popup (message, 30, "Information:", 1) = 2) then wscript.quit
msgbox "continuing to run"
end sub

Can someone help me understand why I can not assign the message box button response then use it in the If statements or Select Case statement?

Thanks.

Dave "Crash" Dummy

unread,
Apr 26, 2013, 2:35:25 PM4/26/13
to
They both work for me if the ws object is set:
Set ws=CreateObject("WScript.Shell")
--
Crash

"I am not young enough to know everything."
~ Oscar Wilde ~

Steve Blake

unread,
Apr 26, 2013, 2:56:43 PM4/26/13
to

Steve Blake

unread,
Apr 26, 2013, 2:59:22 PM4/26/13
to
On Friday, April 26, 2013 2:35:25 PM UTC-4, Dave Crash Dummy wrote:
> Steve Blake wrote: > Okay, this should be a no brainer but I am have an issue with the following code working. > '################## DOES NOT WORK ######################## > > sub DisplayMessage(message) > Mresponse = ws.Popup (message, 30, "Information:", 1) > if (Mresponse = 2) then > msgbox "cancelled selected. Will now quit." > wscript.quit > elseif (Mresponse = -1) then > msgbox "Timed out. Will now quit." > wscript.quit > end if > msgbox "continuing to run" > end sub > > '################## DOES WORK ######################## > > sub DisplayMessage(message) > if (ws.Popup (message, 30, "Information:", 1) = 2) then wscript.quit > msgbox "continuing to run" > end sub > > Can someone help me understand why I can not assign the message box button response then use it in the If statements or Select Case statement? > > Thanks. They both work for me if the ws object is set: Set ws=CreateObject("WScript.Shell") -- Crash "I am not young enough to know everything." ~ Oscar Wilde ~

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Thanks Dave for the quick response.

Interesting, I am setting WS exactly as noted below.

Additional information:
I do get both sub's to display the message and it will timeout (if not selected) so, everything works from that point of view.

However, it appears, once the message is processed (button clicked or timed out) the sub is exited and no code below that line [if (Mresponse... and bleow] is executed and control continues back to calling code.

Additional variables:
Using Microsoft Internet Explorer 8 (Yes, I know.. I work for a very large company that does not allow computer changes)
Operating system is Windows XP Service pact 3 --> (Told you... they will not get with today's technologies)

Dave "Crash" Dummy

unread,
Apr 26, 2013, 3:32:29 PM4/26/13
to
You did not say that you were running the code in a HTML file.
I ran it as a VBS script. You are disabling scripting after the
result message (wscript.quit). The "continuing to run" message
won't display because it is not continuing to run. Try commenting
those lines out.
--
Crash

One man's weed is another man's wildflower.

Steve Blake

unread,
Apr 29, 2013, 8:51:28 AM4/29/13
to
On Friday, April 26, 2013 3:32:29 PM UTC-4, Dave Crash Dummy wrote:
> Steve Blake wrote: > On Friday, April 26, 2013 2:35:25 PM UTC-4, Dave Crash Dummy wrote: >> Steve Blake wrote: > Okay, this should be a no brainer but I am have an issue with the following code working. > '################## DOES NOT WORK ######################## > > sub DisplayMessage(message) > Mresponse = ws.Popup (message, 30, "Information:", 1) > if (Mresponse = 2) then > msgbox "cancelled selected. Will now quit." > wscript.quit > elseif (Mresponse = -1) then > msgbox "Timed out. Will now quit." > wscript.quit > end if > msgbox "continuing to run" > end sub > > '################## DOES WORK ######################## > > sub DisplayMessage(message) > if (ws.Popup (message, 30, "Information:", 1) = 2) then wscript.quit > msgbox "continuing to run" > end sub > > Can someone help me understand why I can not assign the message box button response then use it in the If statements or Select Case statement? > > Thanks. They both work for me if the ws object is set: Set ws=CreateObject("WScript.Shell") -- Crash "I am not young enough to know everything." ~ Oscar Wil de ~ > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > Thanks Dave for the quick response. > > Interesting, I am setting WS exactly as noted below. > > Additional information: > I do get both sub's to display the message and it will timeout (if not selected) so, everything works from that point of view. > > However, it appears, once the message is processed (button clicked or timed out) the sub is exited and no code below that line [if (Mresponse... and bleow] is executed and control continues back to calling code. > > Additional variables: > Using Microsoft Internet Explorer 8 (Yes, I know.. I work for a very large company that does not allow computer changes) > Operating system is Windows XP Service pact 3 --> (Told you... they will not get with today's technologies) You did not say that you were running the code in a HTML file. I ran it as a VBS script. You are disabling scripting after the result message (wscript.quit). The "continuing to run" message won't display because it is not continuing to run. Try commenting those lines out. -- Crash One man's weed is another man's wildflower.

Sorry for the confusion... I only had that message line in as a troubleshooting line to see if the WS.Quit was executing. More specifically, I wanted to determine the jumping point from the SUB. As it is, that message is not (as expected) never displaying. But please keep in mind, that code snippet works. It is the other code snippet that I am trying to get to work that will identify “why” execution will stop. My issue occurs when I select "OK".

So, in summary, I wanted to identify why execution was stopped. Therefore, I had (originally select case) if… ifelse… statements to identify the status. As it runs on my machine, I do NOT get any messages indicating Cancelled, Timed out, or continuing.

Thank you for your time. It is greatly appreciated.

Todd Vargo

unread,
Apr 29, 2013, 2:42:51 PM4/29/13
to
On 4/29/2013 8:51 AM, Steve Blake wrote:
> On Friday, April 26, 2013 3:32:29 PM UTC-4, Dave Crash Dummy wrote:
>> Steve Blake wrote: > On Friday, April 26, 2013 2:35:25 PM UTC-4, Dave Crash Dummy wrote: >> Steve Blake wrote: > Okay, this should be a no brainer but I am have an issue with the following code working. > '################## DOES NOT WORK ######################## > > sub DisplayMessage(message) > Mresponse = ws.Popup (message, 30, "Information:", 1) > if (Mresponse = 2) then > msgbox "cancelled selected. Will now quit." > wscript.quit > elseif (Mresponse = -1) then > msgbox "Timed out. Will now quit." > wscript.quit > end if > msgbox "continuing to run" > end sub > > '################## DOES WORK ######################## > > sub DisplayMessage(message) > if (ws.Popup (message, 30, "Information:", 1) = 2) then wscript.quit > msgbox "continuing to run" > end sub > > Can someone help me understand why I can not assign the message box button response then use it in the If statements or Select Case statement? > > Thanks. They both work for me if the ws object is set: Set ws=CreateObje
ct("WScript.Shell") -- Crash "I am not young enough to know everything." ~ Oscar Wil de ~ > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > Thanks Dave for the quick response. > > Interesting, I am setting WS exactly as noted below. > > Additional information: > I do get both sub's to display the message and it will timeout (if not selected) so, everything works from that point of view. > > However, it appears, once the message is processed (button clicked or timed out) the sub is exited and no code below that line [if (Mresponse... and bleow] is executed and control continues back to calling code. > > Additional variables: > Using Microsoft Internet Explorer 8 (Yes, I know.. I work for a very large company that does not allow computer changes) > Operating system is Windows XP Service pact 3 --> (Told you... they will not get with today's technologies) You did not say that you were running the code in a HTML file. I ran it as a VBS script. You are
disabling scripting after the result message (wscript.quit). The "continuing to run" message won't display because it is not continuing to run. Try commenting those lines out. -- Crash One man's weed is another man's wildflower.
>
> Sorry for the confusion... I only had that message line in as a troubleshooting line to see if the WS.Quit was executing. More specifically, I wanted to determine the jumping point from the SUB. As it is, that message is not (as expected) never displaying. But please keep in mind, that code snippet works. It is the other code snippet that I am trying to get to work that will identify �why� execution will stop. My issue occurs when I select "OK".
>
> So, in summary, I wanted to identify why execution was stopped. Therefore, I had (originally select case) if� ifelse� statements to identify the status. As it runs on my machine, I do NOT get any messages indicating Cancelled, Timed out, or continuing.

The code in question works for me in XP with IE8 installed. Try the
following for debugging purposes.

sub DisplayMessage(message)
Dim ws, Mresponse
Set ws = WScript.CreateObject("WScript.Shell")

Mresponse = ws.Popup (message, 3, "Information:", 1)

MsgBox "Mresponse=" & Mresponse, vbInformation 'for debugging
Wscript.Quit 'for debugging

if (Mresponse = 2) then
msgbox "cancelled selected. Will now quit."
wscript.quit
elseif (Mresponse = -1) then
msgbox "Timed out. Will now quit."
wscript.quit
end if
msgbox "continuing to run"
end sub

If you are still not locating the problem, try adding Option Explicit to
the top of the file and declare your variables to check for any variable
name misspellings.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Steve Blake

unread,
May 3, 2013, 8:58:57 AM5/3/13
to
On Monday, April 29, 2013 2:42:51 PM UTC-4, Todd Vargo wrote:
> On 4/29/2013 8:51 AM, Steve Blake wrote: > On Friday, April 26, 2013 3:32:29 PM UTC-4, Dave Crash Dummy wrote: >> Steve Blake wrote: > On Friday, April 26, 2013 2:35:25 PM UTC-4, Dave Crash Dummy wrote: >> Steve Blake wrote: > Okay, this should be a no brainer but I am have an issue with the following code working. > '################## DOES NOT WORK ######################## > > sub DisplayMessage(message) > Mresponse = ws.Popup (message, 30, "Information:", 1) > if (Mresponse = 2) then > msgbox "cancelled selected. Will now quit." > wscript.quit > elseif (Mresponse = -1) then > msgbox "Timed out. Will now quit." > wscript.quit > end if > msgbox "continuing to run" > end sub > > '################## DOES WORK ######################## > > sub DisplayMessage(message) > if (ws.Popup (message, 30, "Information:", 1) = 2) then wscript.quit > msgbox "continuing to run" > end sub > > Can someone help me understand why I can not assign the message box button response then use it in the If statements or Select Case statement? > > Thanks. They both work for me if the ws object is set: Set ws=CreateObje ct("WScript.Shell") -- Crash "I am not young enough to know everything." ~ Oscar Wil de ~ > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > Thanks Dave for the quick response. > > Interesting, I am setting WS exactly as noted below. > > Additional information: > I do get both sub's to display the message and it will timeout (if not selected) so, everything works from that point of view. > > However, it appears, once the message is processed (button clicked or timed out) the sub is exited and no code below that line [if (Mresponse... and bleow] is executed and control continues back to calling code. > > Additional variables: > Using Microsoft Internet Explorer 8 (Yes, I know.. I work for a very large company that does not allow computer changes) > Operating system is Windows XP Service pact 3 --> (Told you... they will not get with today's technologies) You did not say that you were running the code in a HTML file. I ran it as a VBS script. You are disabling scripting after the result message (wscript.quit). The "continuing to run" message won't display because it is not continuing to run. Try commenting those lines out. -- Crash One man's weed is another man's wildflower. > > Sorry for the confusion... I only had that message line in as a troubleshooting line to see if the WS.Quit was executing. More specifically, I wanted to determine the jumping point from the SUB. As it is, that message is not (as expected) never displaying. But please keep in mind, that code snippet works. It is the other code snippet that I am trying to get to work that will identify �why� execution will stop. My issue occurs when I select "OK". > > So, in summary, I wanted to identify why execution was stopped. Therefore, I had (originally select case) if� ifelse� statements to identify the status. As it runs on my machine, I do NOT get any messages indicating Cancelled, Timed out, or continuing. The code in question works for me in XP with IE8 installed. Try the following for debugging purposes. sub DisplayMessage(message) Dim ws, Mresponse Set ws = WScript.CreateObject("WScript.Shell") Mresponse = ws.Popup (message, 3, "Information:", 1) MsgBox "Mresponse=" & Mresponse, vbInformation 'for debugging Wscript.Quit 'for debugging if (Mresponse = 2) then msgbox "cancelled selected. Will now quit." wscript.quit elseif (Mresponse = -1) then msgbox "Timed out. Will now quit." wscript.quit end if msgbox "continuing to run" end sub If you are still not locating the problem, try adding Option Explicit to the top of the file and declare your variables to check for any variable name misspellings. -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages)

Thanks Todd. Apparently the redefinition was required within the Sub even though these two lines was at the top of my script. This is good to know.

Dim ws, Mresponse
Set ws = WScript.CreateObject("WScript.Shell")

Seems to be the only thing different and it worked. I even re-wrote as a Case statement.

Todd Vargo

unread,
May 4, 2013, 12:59:20 AM5/4/13
to
On 5/3/2013 8:58 AM, Steve Blake wrote:
>
> Thanks Todd. Apparently the redefinition was required within the Sub
> even though these two lines was at the top of my script. This is
> good to know.
>
> Dim ws, Mresponse
> Set ws = WScript.CreateObject("WScript.Shell")
>
> Seems to be the only thing different and it worked. I even re-wrote
> as a Case statement.

I'm glad I could help.

On a side note, I wish google would fix their posting system so their
posts are easier to read.

Mayayana

unread,
May 4, 2013, 8:51:56 AM5/4/13
to
| On a side note, I wish google would fix their posting system so their
| posts are easier to read.
|

There's no excuse for anyone using Google groups
in the first place.
Even if people can't figure out how to use newsgroups
properly, there's still no excuse for bottom-posting
without any attempt to edit the pre-existing text,
as though they were working in a console window.
That's just plain laziness and thoughtlessness.

... On the bright side, at least this discussion
isn't from 2007. :)


Todd Vargo

unread,
May 5, 2013, 12:15:03 AM5/5/13
to
I was referring to google's removal of linefeeds from quoted text
creating excessively long lines and just permitting excessively long
wrapped lines to be posted in general.

I lose interest when a google poster refuses to correct google's
offensive posting rules.

Dave "Crash" Dummy

unread,
May 5, 2013, 11:03:19 AM5/5/13
to
Todd Vargo wrote:
> On 5/4/2013 8:51 AM, Mayayana wrote:
>> | On a side note, I wish google would fix their posting system so
>> their | posts are easier to read. |
>>
>> There's no excuse for anyone using Google groups in the first
>> place. Even if people can't figure out how to use newsgroups
>> properly, there's still no excuse for bottom-posting without any
>> attempt to edit the pre-existing text, as though they were working
>> in a console window. That's just plain laziness and
>> thoughtlessness.
>>
>> ... On the bright side, at least this discussion isn't from 2007.
>> :)
>
> I was referring to google's removal of linefeeds from quoted text
> creating excessively long lines and just permitting excessively long
> wrapped lines to be posted in general.

That drives me nuts. It makes it impossible to follow an ongoing dialog
without opening all the relevant posts at once. It is really maddening
when a particular script is under discussion and it turns into mind
numbing mush.

> I lose interest when a google poster refuses to correct google's
> offensive posting rules.

Ditto.
--
Crash

"The fewer the facts, the stronger the opinion."
~ Arnold H. Glasow ~
0 new messages