Solved

Problems with Const in VBScript Class?

Posted on 2003-11-24
3
1,676 Views
Last Modified: 2010-05-19
Ok, I'm trying to be a "good" programmer by following the rules my professors drilled into my head years ago.  I'm currently writing some administration scripts in VBScript and have encapsulated a lot of my code into various classes.  Now I'm running to a problem when I declare a Const in the class, it gives me: "Syntax Error (800A03EA) Compilation Error" right at the point of declaring the Const.  It doesn't matter if I create it as a Private or Public Const.

I'm betting if I change them to variables they'll work, but I'd rather stay away from that since I've been doing a good job of keeping the code clean so far.  Is there a problem in VBScript that prevents declaring a Const in a class?  If so, is there a work-around outside of using variables?
0
Comment
Question by:CiQuat
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
d0zerz earned 50 total points
ID: 9813225
This page seems to suggest that in VBScript 5.0 there's a bug that prevents constants from being delcared in classes:

http://www.webmasterworld.com/forum47/680.htm

if you're concerned with good code (that's a good thing), assuming this guy is right in asserting that the const/class thing is a bug... just declare the variable as private to only access it through class methods..  That way you can ensure that the variable will never be touched (assuming you're the only one working on the class and you're not sloppy in accidentally assigning it)
0
 

Author Comment

by:CiQuat
ID: 9817913
Thank you d0zerz.  I'm also interested if anyone has found a workaround for Const (besides using class-private variables, as I was forced to do).
0
 

Author Comment

by:CiQuat
ID: 9849785
Well, I guess no one has anything to add.  Awarding points.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question