Constant definition

  • Thread starter Thread starter Lurc
  • Start date Start date
L

Lurc

Dear all,

From forum, I found some constants definition like
Const ERROR_SUCCESS = 0&
Const ERROR_BADDB = 1009&

I wonder what is the meaning for sign & here?
 
That's some pretty old looking code. The & and % characters can be used as
type characters for Long and Integer (respectively). VB.NET includes them
only for historical purposes and their use is discouraged. You should
declare your variables instead:

Const ERROR_SUCCESS As Long = 0
Const ERROR_BADDB As Long = 1009

If you need to use a Long literal in code, use "L" instead of "&". (i.e.
123L)
 
Many thanks, Beth.

--
Best regards,
RL
Beth Massi said:
That's some pretty old looking code. The & and % characters can be used as
type characters for Long and Integer (respectively). VB.NET includes them
only for historical purposes and their use is discouraged. You should
declare your variables instead:

Const ERROR_SUCCESS As Long = 0
Const ERROR_BADDB As Long = 1009

If you need to use a Long literal in code, use "L" instead of "&". (i.e.
123L)
 
Remember Beth that a Long in VB6 is an Integer in VB.Net and that an Integer
in VB6 is a Short in VB.Net.

Const ERROR_SUCCESS As Integer = 0
Const ERROR_BADDB As Integer = 1009
 
Since the question was posted on a VB.NET forum I figured the code in the
original question was VB.NET, not VB6.
 

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

Back
Top