Wrox Programmer Forums
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 8th, 2003, 01:38 AM
Authorized User
Join Date: Jun 2003
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Static vs constant

What is the difference between declaring something as Static vs declaring the same thing as a constant?
When does one use one over the other


Static msg as String
msg= Save Changes


Const msg as String = "Save Changes"

Old December 10th, 2003, 03:33 PM
Authorized User
Join Date: Nov 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

A static variable in a procedure holds the value even after the procedure ends. Variables have a scope, which means that it can be accessed through the whole module if it is a module level variable, or through the whole procedure in which it is defined.
When the procedure ends the variable loses its value if it is not a static variable.
Variables can hold different values but constants are used to represent a constant value.
Old December 10th, 2003, 09:12 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts

It's got something to do with constants being constant and variables being variable - you can't vary a constant, but you can vary a variable

I am a loud man with a very large hat. This means I am in charge

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# constant functions viveksrivastava C# 4 December 6th, 2007 10:44 PM
Constant pointer and pointer to a constant amit_mande@yahoo.com C++ Programming 2 June 5th, 2007 01:39 AM
non-static reports to static html files miamikk ASP.NET 2.0 Basics 0 June 4th, 2007 01:48 PM
Constant in VBScript savoym VBScript 2 May 18th, 2005 06:53 AM
Backend as a constant Steven Access 1 June 29th, 2003 11:49 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.