Constant definition

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lurc

    Constant definition

    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?

    --
    Best regards,
    RL


  • Beth Massi [Architect MVP]

    #2
    Re: Constant definition

    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)

    "Lurc" <lurchot@spam.h otmail.com> wrote in message
    news:ebBL6TdUFH A.3400@TK2MSFTN GP10.phx.gbl...[color=blue]
    > 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?
    >
    > --
    > Best regards,
    > RL
    >
    >[/color]


    Comment

    • Lurc

      #3
      Re: Constant definition

      Many thanks, Beth.

      --
      Best regards,
      RL
      "Beth Massi [Architect MVP]" <bmassi@comcast .net> дÈëÓʼþ
      news:eZpGIveUFH A.3188@TK2MSFTN GP09.phx.gbl...[color=blue]
      > 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)
      >
      > "Lurc" <lurchot@spam.h otmail.com> wrote in message
      > news:ebBL6TdUFH A.3400@TK2MSFTN GP10.phx.gbl...[color=green]
      > > 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?
      > >
      > > --
      > > Best regards,
      > > RL
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Stephany Young

        #4
        Re: Constant definition

        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


        "Beth Massi [Architect MVP]" <bmassi@comcast .net> wrote in message
        news:eZpGIveUFH A.3188@TK2MSFTN GP09.phx.gbl...[color=blue]
        > 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)
        >
        > "Lurc" <lurchot@spam.h otmail.com> wrote in message
        > news:ebBL6TdUFH A.3400@TK2MSFTN GP10.phx.gbl...[color=green]
        >> 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?
        >>
        >> --
        >> Best regards,
        >> RL
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Beth Massi [Architect MVP]

          #5
          Re: Constant definition

          Since the question was posted on a VB.NET forum I figured the code in the
          original question was VB.NET, not VB6.

          "Stephany Young" <noone@localhos t> wrote in message
          news:erObeTfUFH A.2172@TK2MSFTN GP15.phx.gbl...[color=blue]
          > 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
          >
          >
          > "Beth Massi [Architect MVP]" <bmassi@comcast .net> wrote in message
          > news:eZpGIveUFH A.3188@TK2MSFTN GP09.phx.gbl...[color=green]
          >> 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)
          >>
          >> "Lurc" <lurchot@spam.h otmail.com> wrote in message
          >> news:ebBL6TdUFH A.3400@TK2MSFTN GP10.phx.gbl...[color=darkred]
          >>> 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?
          >>>
          >>> --
          >>> Best regards,
          >>> RL
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Constant definition

            "Lurc" <lurchot@spam.h otmail.com> schrieb:[color=blue]
            > 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?[/color]

            In addition to the other replies:

            Visual Basic Language Specification -- 2.2.1 Type Characters
            <URL:http://msdn.microsoft. com/library/en-us/vbls7/html/vblrfVBSpec2_2_ 1.asp>

            Visual Basic Language Concepts -- Type Characters
            <URL:http://msdn.microsoft. com/library/en-us/vbcn7/html/vbconTypeCharac ters.asp>

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

            Comment

            Working...