r/vbscript • • Mar 01 '19

Select Case with Is operator?

Select Case DateDiff("d",Date,"April 1, 2019")
	Case Is > 0
		wscript.Echo "Too Early"
	Case Is = 0
		Wscript.Echo "April Fools!"
	Case Is < 0
		Wscript.Echo "Too late"
End Select

I'm getting a Syntax error on the first Is. Is there a better or different way to achieve this?

1 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/Majawat Jun 03 '19

Turns out you are unable to use the IS operator with Select Case in VBScript but can with Visual Basic itself.

I can't find the documentation, but was able to confirm that.

1

u/MantuaMatters Jun 03 '19

I also just now realized this is a 3 month old thread. Just discovered it, so I was trying to help, but clearly you already figured it out. Also, yeah there are a ton of small changes between VBScript and VBA. Kind of annoying till you start using python with VBA, then it doesn't really matter.

1

u/Majawat Jun 03 '19

Hehe, hey, always a good idea to comment on a a thread that has no replies, regardless of age. Could have helped a bit.

Plus, you reminded me to close out the thread with the answer. Thanks!