Solved

Problems with Const in VBScript Class?

Posted on 2003-11-24
3
1,672 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now