how to define a constant in VB

M

Maileen

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
 
M

Maileen

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
 
H

Herfried K. Wagner [MVP]

Maileen said:
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++.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top