Hi Michael,
Unfortunately, you can't do exactly what you want. #Const constants can
only be used in #If directives. For example:
#Const TEST_CONST
some code
# If TEST_CONST = "TEST" Then
some conditional code
# End If
You can do close to what you want in one of two ways. First something like
#Const MODE_STR = "Mode1"
# If MODE_STR = "Mode1" Then
Private Const MODE_STR = "Mode1"
# End If
Dim strMode As String = MODE_STR
It's probably simpler, however, to just use Const.
Private Const MODE_STR = "Mode1"
Hope this helps,
Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).
--------------------
From: "Michael Fitzpatrick" <mm*****@codeinsight.com>
Subject: Setting variables at Compile Time using #Const
Date: Tue, 24 Feb 2004 09:02:03 -0800
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eU**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 165.152.34.237
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:184377
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
Is it possible to set a variable with the value of a compile time constant.
Example:
#Const MODE_STR = "Mode1"
dim strMode as String = MODE_STR
Obviously this doesn't work. Is there a way to achieve the same thing???
--
: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: my email address zf****@pbqrvafvtug.com is encrypted with www.rot13.org