By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

how to define a constant in VB

P: n/a
Hi,

I would like to know how to define a constant in VB.NET.
i've tried #CONST strMyString = 1001

in my code laster, i use this constant, but VB.NET is telling me that it can not be converted due to my "Explicit Off" option.
I tried to convert it in long, but nothing change...

so where can be the issue ?
thx,

Maileen
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
i just would like to precise my thought.
i can define a constant like that :

public const strTest as Long = 1001

I know that it will work, but i'm looking for something like in C++ : #define test 1001

Maileen

Maileen wrote:
Hi,

I would like to know how to define a constant in VB.NET.
i've tried #CONST strMyString = 1001

in my code laster, i use this constant, but VB.NET is telling me that it
can not be converted due to my "Explicit Off" option.
I tried to convert it in long, but nothing change...

so where can be the issue ?
thx,

Maileen

Nov 21 '05 #2

P: n/a
"Maileen" <no*****@nospam.com> schrieb:
i can define a constant like that :

public const strTest as Long = 1001

I know that it will work, but i'm looking for something like in C++ :
#define test 1001


I suggest to use a constant! VB.NET doesn't support text-replacements as
possible with '#define' in C/C++.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.