Solved

Problems with Const in VBScript Class?

Posted on 2003-11-24
3
1,669 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
Comment Utility
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
Comment Utility
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
Comment Utility
Well, I guess no one has anything to add.  Awarding points.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

6 Experts available now in Live!

Get 1:1 Help Now