Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 27th, 2006, 9:51 AM   #1
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
VBScript - Timed Message Box?

I am searching around on google and will continue to do so till i figure this out, but figured i'de post here as well.

Is there an easy way to script a MsgBox that is timed. Once the time is over, it will close itself. From what i've found i can do this through VB.net, but I can't find it for Script yet. Any suggestions would be greatly appreciated.

I do know how to do the Msgbox command to get one to come up, but i can only do it with required user interaction. This is what I don't want.
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Old Jun 27th, 2006, 10:09 AM   #2
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 242
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
Smile

This is very similar to what you need to do, only instead of opening a msgbox when the time is up, open it at the beginning and close it at the end.

'************************************************************* 
'This program makes use of a recursive procedure HandleTime.
'The important aspects of the code are "Status" and "setTimeOut". 
'Status is an attribute of the Window object in VBScript and is used to 
'change the status message of the active window. 
'setTimeOut is a VBScript function that tells after how much time the timer 
'would stop and accordingly it calls a function passed into it to take some 
'action when the time is up.
'This procedure calls its self after every 1 sec (I have taken 1sec = 950ms
' here) and accordingly the variables hr, min and sec are decremented. 
'************************************************************* 
Sub HandleTime 
    if hr=0 and min=0 and sec=0 then 
        EndTime 
        '**When hr, min and sec are all 0, this means that the time is up 
        '**and EndTime procedure is 'called. 
    elseif min>=0 and sec>0 then 
        sec=sec-1 
        status=hr & ":" & min & ":" & sec 
        '**Whenever the second changes the Status of the window has to 
        'be changed. 
        intTimerID=setTimeOut("HandleTime",950, "VBScript") 
        '**setTimeOut function returns a unique timer id that is used to 
        'keep track of the time. 
        '**When the time is up the timer id is destroyed automatically. 
    elseif min>0 and sec=0 then 
        min=min-1 
        sec=59 
        status=hr & ":" & min & ":" & sec 
        intTimerID=setTimeOut("HandleTime",950, "VBScript") 
    elseif hr>=0 and min=0 then 
        hr=hr-1 
        min=59 
        sec=59 
        status=hr & ":" & min & ":" & sec 
        intTimerID=setTimeOut("HandleTime",950, "VBScript") 
    end if 
End Sub 

Sub EndTime 
    clearTimeOut intTimerID 
    '**clearTimeOut is a built in procedure of VBScript which is used to 
    '**clear and destroy the timer id explicitly 
    status = "Your Time Ended" 
    '**When the time ends the status bar displays this message. 
    msgbox "Time Up" 
End Sub

taken from:
http://www.codeproject.com/asp/webtimer.asp
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Old Jun 27th, 2006, 10:13 AM   #3
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
Melbolt, thank you very much. I'll go ahead and mess with that till I understand it completely, then modify to work the way I need! *thumbs up*
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Old Jun 27th, 2006, 2:09 PM   #4
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
After reading through the ElseIf and making sense of it all i really like how they use it counts down. My problem is, I want the box to close automatically after 6 seconds without user interaction. More like a, "ok, things are working" and gone. I might be stabbing in the dark at something that doesn't exist. Also, i am probably not experienced enough to know all the internal functions or how to properly search them for the right key words. Once again, thank you for all the help.
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Old Jun 27th, 2006, 2:13 PM   #5
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
Ok, found a link the directs me to using the PopUp method. This is bassically what it's saying to do.

Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32

Set objShell = CreateObject("Wscript.Shell")

intReturn = objShell.Popup("Do you want to delete this file?", _
    10, "Delete File", wshYesNoDialog + wshQuestionMark)

If intReturn = wshYes Then
    Wscript.Echo "You clicked the Yes button."
ElseIf intReturn = wshNo Then
    Wscript.Echo "You clicked the No button."
Else
    Wscript.Echo "The popup timed out."
End If

The rest of the information can be located at Linky!
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC