Print Page | Close Window

Why using const?

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=25005
Printed Date: 04 April 2026 at 5:20am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Why using const?
Posted By: efscl
Subject: Why using const?
Date Posted: 13 December 2007 at 1:32pm
Hi Borg, Hi Senior ASP Programmers,

in the forum you are using "const" at different places.

1.) I know this is a "clean" programmning.
2.) Sometimes its written that constants have a better performance than variables
3.) if you would that a variable never will change: use constant

Problem:
I am using one test server and one live server with "the same" code.  So i have to change for example in functions_member_API.asp the

const strMemberAPILoginURL = "http://test.liveserver.com/login.asp"
to
const strMemberAPILoginURL = "http://www.liveserver.com/login.asp"

You writting in the comment above the code that i have to use the full URL "http://..." and not  "/login.asp".

But manually change everytime is not a good choice.

Const s
trMemberAPILoginURL = "http://" & Req.SV("HTTP_HOST") & "/login.asp"

is not working with Const. So i have to use a variable.

Ok - now the question Smile:
Is there any other important reason for using a constant instead of a variable?

thx all for your feedback
Sebastian




Replies:
Posted By: WebWiz-Bruce
Date Posted: 13 December 2007 at 1:45pm
The only reason is for clean programming and because it's meant to give better performance.

So that the variable can be assigned different values just declare the variable using a Dim line and then remove the Const.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: efscl
Date Posted: 13 December 2007 at 1:53pm
again: faster reply than the fire departement allows ;O)

thx n have a great day



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net