Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox on alternate days

blackvan253

Technical User
Sep 13, 2024
1
0
1
Hi, I'm only a beginner with VBS - basic MsgBox stuff and functions only. I have a question I hope you can help me with.

Using a VBScript, how can I trigger a MsgBox in Windows on alternate days?

Eg. open a MsgBox beginning on, say, Monday, then cycle through Wed, Fri, Sun, Tue, Thu, Sat, Mon repeat etc.

Or, put another way, start on DateX, then DateX + 2, DateX + 4, DateX + 6 etc.

I'd prefer the first way rather than rely on any specific start date.

I can do this with Excel VBA but I have the benefit of storing a value in a variable, updating that variable and then saving the Excel file. I don't know how to translate that procedure into a VBScript.

Thanks!
 
I am not a VB Scripter, but I hope the logic in this VBA code is helpful.

Dim lngLastDay as long
Dim blnShowOnEvenDays as boolean

' Determine the last day of the previous month
lngLastDay = DateSerial(Year(Now), Month(Now), 1) - 1

' If the last day of the previous month was 29 or 31 (odd) then show the msgbox on even days, otherwise odd days
if lngLastDay mod 2 = 1 then blnShowOnEvenDays = true else blnShowOnEvenDays = false
if blnShowOnEvenDays = true and day(now) mod 2 = 0 then ' DO YOUR MESSAGE BOX
if blnShowOnEvenDays =false and day(now) mod 2 = 1 then ' DO YOUR MESSAGE BOX
 
Hi -

Like most scripting languages, VBS is typically a one-and-done execution. Given this behavior, the easiest way to accomplish this task is to run your script from the Windows Task Scheduler.

The bigger issue is that Microsoft has announced an end-of-life for VBS. The cscript.exe and wscript.exe programs will be phased out of Windows over the next 2 OS versions. I recommend that you find a way to express your automation need in another language, like PowerShell.
 
Last edited:
..
The bigger issue is that Microsoft has announced an end-of-life for VBS. The cscript.exe and wscript.exe programs will be phased out of Windows over the next 2 OS versions. I recommend that you find a way to express your automation need in another language, like PowerShell.

But VBscript will definitely be with us for a few more years.
I downloaded the virtual machine from W11 and VBscript is still there:
 
But VBscript will definitely be with us for a few more years.
I downloaded the virtual machine from W11 and VBscript is still there:
Doesn't make my answer incorrect. :)

If you're using existing code, go for it. I just wouldn't start a new programming project in that language. Native Intellisense support has already been removed from VSCode (though you may be able to find non-MS support).
 
>The cscript.exe and wscript.exe programs will be phased out of Windows over the next 2 OS versions

To the best of my knowledge, Microsoft have not made any official statement about when these, or any other of the other dlls required to support vbscript will be removed. At the very, very earliest it might be 2027

>Native Intellisense support has already been removed from VSCode
I didn't think VSCode had native vbs support. (beyond the basic out of the box simplistic syntax highlighting and word completion - both of which are still working fine in my instance of VScode, v 1.93.1). Shows what I know.

But I'd agree that starting a major new project in vbscript would be an optimistic act. But then, much as I liked it, I'd argue that it was always an act of optimism to write a major project in vbscript ...
 

Part and Inventory Search

Sponsor

Back
Top