PDA

Click to See Complete Forum and Search --> : What is the Const command?


rino_2
Jan 10th, 2000, 11:03 AM
Hi,

I'm learning API and I offten see the Const command but I don't have a clue what it is and does. Could you please tell me?

Thanks

Aaron Young
Jan 10th, 2000, 11:11 AM
It means Constant, a Variable who's value doesn't change.

When using things like Window Styles it's easier to code WM_BORDER, or WM_DLGFRAME, rather than trying to remember the actual values.

VB uses a whole host of Constants, ie.

WindowState = vbMinimized

vbMinimized is a Constant with a value always of 1

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

Dreamlax
Jun 12th, 2002, 07:14 PM
A variable must change, hence it's name... if it were constant, it wouldn't be a variable!

A better explanation would be that a constant has a particular value which doesn't change.

cafeenman
Jun 12th, 2002, 07:23 PM
In the declarations section of a Module, you can declare a const as public or private. You can also use Dim, but that's not recommended.

You must use Dim if you declare a const in a procedure. I don't think you can have a public const in a form or a class module.

Also, you can declare the data type of the const

All these are legal in a module but you can only have one of them since the name is the same.


Public Const MY_CONSTANT As Long = 1
Public Const MY_CONSTANT = 1
Private Const MY_CONSTANT As Long = 1
Private Const MY_CONSTANT = 1
Dim Const MY_CONSTANT =1