Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

constant variable help please 1

Status
Not open for further replies.

MysticFallout

Technical User
Sep 21, 2002
14
US
I am trying to make a constant variable so I will not have to constantly re-create the variable throughout my application. The variable I am trying to make utilizes the GetSetting function. I don't understand this type of "Coding" very well, but I am reading up on it as I write this, but so far no idea on how I would do this.

Code:
private const showPrev as string = GetSetting("Wallpaper", "options", "Allow Preview")

But I am getting an error. "Constant Expression Required". Could someone please advise me on how I could do this?

Thank you in advance! :)
 
Constants are defined at compile time. Therefore, any value that you give them must also be resolved at compile time. The GetSetting() call does not fall into that category, as what it returns can change while a program is running (Ex: user runs RegEdit while program is running & changes the value).

Probably what you can do is put it in a class, inside a "Property Get", with no matching "Property Let". That way it behaves as if it were read-only.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top