can't use Currency in a function declration!

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

    can't use Currency in a function declration!

    Hi

    I want to use the following declarations but vb dotnet keeps complaining
    that currency can't be used because it private ?

    I have tried it in a module and in the declaration pare same error!



    Private Declare Function QueryPerformanc eFrequency Lib "kernel32" (ByVal
    lpFrequency As Currency) As Long

    Private Declare Function QueryPerformanc eCounter Lib "kernel32" (ByVal
    lpPerformanceCo unt As Currency) As Long



  • Armin Zingler

    #2
    Re: can't use Currency in a function declration!

    "Adrian" <Adrian@nospamh otmail.com.uk> schrieb[color=blue]
    > Hi
    >
    > I want to use the following declarations but vb dotnet keeps
    > complaining that currency can't be used because it private ?
    >
    > I have tried it in a module and in the declaration pare same error!
    >
    >
    >
    > Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
    > (ByVal lpFrequency As Currency) As Long
    >
    > Private Declare Function QueryPerformanc eCounter Lib "kernel32"
    > (ByVal lpPerformanceCo unt As Currency) As Long[/color]


    These are declarations for the wrong language (VB6). In VB.Net:


    Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
    (ByRef lpFrequency As Long) As Boolean

    Private Declare Function QueryPerformanc eCounter Lib "kernel32"
    (byref lpPerformanceCo unt As long) As boolean


    Armin

    Comment

    • Adrian

      #3
      Re: can't use Currency in a function declration!

      Thanks for the quick reply and help

      "Armin Zingler" <az.nospam@free net.de> wrote in message
      news:uPTBSpjjFH A.476@TK2MSFTNG P14.phx.gbl...[color=blue]
      > "Adrian" <Adrian@nospamh otmail.com.uk> schrieb[color=green]
      >> Hi
      >>
      >> I want to use the following declarations but vb dotnet keeps
      >> complaining that currency can't be used because it private ?
      >>
      >> I have tried it in a module and in the declaration pare same error!
      >>
      >>
      >>
      >> Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
      >> (ByVal lpFrequency As Currency) As Long
      >>
      >> Private Declare Function QueryPerformanc eCounter Lib "kernel32"
      >> (ByVal lpPerformanceCo unt As Currency) As Long[/color]
      >
      >
      > These are declarations for the wrong language (VB6). In VB.Net:
      >
      >
      > Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
      > (ByRef lpFrequency As Long) As Boolean
      >
      > Private Declare Function QueryPerformanc eCounter Lib "kernel32"
      > (byref lpPerformanceCo unt As long) As boolean
      >
      >
      > Armin[/color]


      Comment

      • Adrian

        #4
        Re: can't use Currency in a function declration!

        Sorry it still gives the same error!?



        "Adrian" <Adrian@nospamh otmail.com.uk> wrote in message
        news:dbp4nr$pf2 $1@nwrdmz02.dmz .ncs.ea.ibs-infra.bt.com...[color=blue]
        > Thanks for the quick reply and help
        >
        > "Armin Zingler" <az.nospam@free net.de> wrote in message
        > news:uPTBSpjjFH A.476@TK2MSFTNG P14.phx.gbl...[color=green]
        >> "Adrian" <Adrian@nospamh otmail.com.uk> schrieb[color=darkred]
        >>> Hi
        >>>
        >>> I want to use the following declarations but vb dotnet keeps
        >>> complaining that currency can't be used because it private ?
        >>>
        >>> I have tried it in a module and in the declaration pare same error!
        >>>
        >>>
        >>>
        >>> Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
        >>> (ByVal lpFrequency As Currency) As Long
        >>>
        >>> Private Declare Function QueryPerformanc eCounter Lib "kernel32"
        >>> (ByVal lpPerformanceCo unt As Currency) As Long[/color]
        >>
        >>
        >> These are declarations for the wrong language (VB6). In VB.Net:
        >>
        >>
        >> Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
        >> (ByRef lpFrequency As Long) As Boolean
        >>
        >> Private Declare Function QueryPerformanc eCounter Lib "kernel32"
        >> (byref lpPerformanceCo unt As long) As boolean
        >>
        >>
        >> Armin[/color]
        >
        >[/color]


        Comment

        • Adrian

          #5
          Re: can't use Currency in a function declration!

          this what I'm trying to do, using the code bellow I insert a call to a web
          service at the "some code line" and I want to know in milisecs how long it
          takes to return a response.

          Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
          (lpFrequency As Currency) As Long
          Private Declare Function QueryPerformanc eCounter Lib "kernel32"
          (lpPerformanceC ount As Currency) As Long



          Dim curFreq as Currency
          Dim curStart as Currency
          Dim curEnd as Currency
          Dim dblResult as Double

          QueryPerformanc eFrequency curFreq 'Get the timer frequency
          QueryPerformanc eCounter curStart 'Get the start time

          'Some code to test

          QueryPerformanc eCounter curEnd 'Get the end time
          dblResult = (curEnd - curStart) / curFreq 'Calculate the duration (in
          seconds)

          taken from http://gpwiki.org/index.php/VB:QueryPerformanceCounter


          "Adrian" <Adrian@nospamh otmail.com.uk> wrote in message
          news:dbp4qg$d3f $1@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...[color=blue]
          > Sorry it still gives the same error!?
          >
          >
          >
          > "Adrian" <Adrian@nospamh otmail.com.uk> wrote in message
          > news:dbp4nr$pf2 $1@nwrdmz02.dmz .ncs.ea.ibs-infra.bt.com...[color=green]
          >> Thanks for the quick reply and help
          >>
          >> "Armin Zingler" <az.nospam@free net.de> wrote in message
          >> news:uPTBSpjjFH A.476@TK2MSFTNG P14.phx.gbl...[color=darkred]
          >>> "Adrian" <Adrian@nospamh otmail.com.uk> schrieb
          >>>> Hi
          >>>>
          >>>> I want to use the following declarations but vb dotnet keeps
          >>>> complaining that currency can't be used because it private ?
          >>>>
          >>>> I have tried it in a module and in the declaration pare same error!
          >>>>
          >>>>
          >>>>
          >>>> Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
          >>>> (ByVal lpFrequency As Currency) As Long
          >>>>
          >>>> Private Declare Function QueryPerformanc eCounter Lib "kernel32"
          >>>> (ByVal lpPerformanceCo unt As Currency) As Long
          >>>
          >>>
          >>> These are declarations for the wrong language (VB6). In VB.Net:
          >>>
          >>>
          >>> Private Declare Function QueryPerformanc eFrequency Lib "kernel32"
          >>> (ByRef lpFrequency As Long) As Boolean
          >>>
          >>> Private Declare Function QueryPerformanc eCounter Lib "kernel32"
          >>> (byref lpPerformanceCo unt As long) As boolean
          >>>
          >>>
          >>> Armin[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Armin Zingler

            #6
            Re: can't use Currency in a function declration!

            "Adrian" <Adrian@nospamh otmail.com.uk> schrieb
            [color=blue]
            > taken from http://gpwiki.org/index.php/VB:QueryPerformanceCounter[/color]


            Again, this code is for the wrong language. Well, not the language is wrong,
            but you are using it in the wrong place. It is VB6 code. You are probably
            using VB.net, aren't you? Both are different. Use my declaration. There is
            no Currency data type. Use 'Long' as the parameters according to the
            declaration.


            Armin

            Comment

            • Adrian

              #7
              Re: can't use Currency in a function declration!

              OK thanks again, I will try it when I get home and let you know how it goes!

              And yes I'm trying to use VB dotnet

              Thanks

              "Armin Zingler" <az.nospam@free net.de> wrote in message
              news:%23J8hTTkj FHA.3656@TK2MSF TNGP09.phx.gbl. ..[color=blue]
              > "Adrian" <Adrian@nospamh otmail.com.uk> schrieb
              >[color=green]
              >> taken from http://gpwiki.org/index.php/VB:QueryPerformanceCounter[/color]
              >
              >
              > Again, this code is for the wrong language. Well, not the language is
              > wrong,
              > but you are using it in the wrong place. It is VB6 code. You are probably
              > using VB.net, aren't you? Both are different. Use my declaration. There is
              > no Currency data type. Use 'Long' as the parameters according to the
              > declaration.
              >
              >
              > Armin
              >[/color]


              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: can't use Currency in a function declration!

                "Adrian" <Adrian@nospamh otmail.com.uk> schrieb:[color=blue]
                > I want to use the following declarations but vb dotnet keeps complaining
                > that currency can't be used because it private ?
                >
                > I have tried it in a module and in the declaration pare same error!
                >
                >
                >
                > Private Declare Function QueryPerformanc eFrequency Lib "kernel32" (ByVal
                > lpFrequency As Currency) As Long[/color]

                See:

                <URL:http://www.pinvoke.net/default.aspx/coredll/QueryPerformanc eCounter%20.htm l>

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

                Comment

                • m.posseth

                  #9
                  Re: can't use Currency in a function declration!

                  Armin ,,,,,, Long ????

                  No not long,,, you should use the decimal datatype for currency values

                  regards

                  Michel Posseth [MCP]

                  "Adrian" <Adrian@nospamh otmail.com.uk> schreef in bericht
                  news:dbq6pn$ehi $1@nwrdmz03.dmz .ncs.ea.ibs-infra.bt.com...[color=blue]
                  > OK thanks again, I will try it when I get home and let you know how it
                  > goes!
                  >
                  > And yes I'm trying to use VB dotnet
                  >
                  > Thanks
                  >
                  > "Armin Zingler" <az.nospam@free net.de> wrote in message
                  > news:%23J8hTTkj FHA.3656@TK2MSF TNGP09.phx.gbl. ..[color=green]
                  >> "Adrian" <Adrian@nospamh otmail.com.uk> schrieb
                  >>[color=darkred]
                  >>> taken from http://gpwiki.org/index.php/VB:QueryPerformanceCounter[/color]
                  >>
                  >>
                  >> Again, this code is for the wrong language. Well, not the language is
                  >> wrong,
                  >> but you are using it in the wrong place. It is VB6 code. You are probably
                  >> using VB.net, aren't you? Both are different. Use my declaration. There
                  >> is
                  >> no Currency data type. Use 'Long' as the parameters according to the
                  >> declaration.
                  >>
                  >>
                  >> Armin
                  >>[/color]
                  >
                  >[/color]


                  Comment

                  • Armin Zingler

                    #10
                    Re: can't use Currency in a function declration!

                    "m.posseth" <posseth@planet .nl> schrieb[color=blue]
                    > Armin ,,,,,, Long ????
                    >
                    > No not long,,, you should use the decimal datatype for currency
                    > values[/color]

                    They are not currency values.

                    Currency has been used in VB6 only because there was no other 8 bytes
                    integer (or better: scaled integer) data type. Now we have Long.


                    Armin

                    Comment

                    • m.posseth

                      #11
                      Re: can't use Currency in a function declration!

                      Armin ,,,
                      '
                      I sure remember that when i moved from VB 6 to VB.Net that in the
                      conversion guides was stated that the decimal datatype should be used to
                      hold currency values

                      "Nor is the Currency data type. Instead, use the new Decimal data type,
                      which can handle more digits on both sides of the decimal point, for all
                      money variables and calculations. Decimal is also directly supported by the
                      common language runtime."


                      after a small search




                      after some googling i found that some people recomend a 64 bit integer to
                      hold currency values

                      regards

                      Michel Posseth


                      "Armin Zingler" <az.nospam@free net.de> schreef in bericht
                      news:evMTCrRkFH A.3144@TK2MSFTN GP12.phx.gbl...[color=blue]
                      > "m.posseth" <posseth@planet .nl> schrieb[color=green]
                      >> Armin ,,,,,, Long ????
                      >>
                      >> No not long,,, you should use the decimal datatype for currency
                      >> values[/color]
                      >
                      > They are not currency values.
                      >
                      > Currency has been used in VB6 only because there was no other 8 bytes
                      > integer (or better: scaled integer) data type. Now we have Long.
                      >
                      >
                      > Armin[/color]


                      Comment

                      • Tom Shelton

                        #12
                        Re: can't use Currency in a function declration!

                        On 2005-07-27, m.posseth <posseth@planet .nl> wrote:[color=blue]
                        > Armin ,,,
                        > '
                        > I sure remember that when i moved from VB 6 to VB.Net that in the
                        > conversion guides was stated that the decimal datatype should be used to
                        > hold currency values
                        >[/color]

                        That's true, except in this case - since they aren't storing currency
                        values. The need a 64-bit integer. In VB6, you had to use a currency
                        value (since that's what they were interanlly). In VB.NET you use Long,
                        which is a 64-bit integer.
                        [color=blue]
                        > "Nor is the Currency data type. Instead, use the new Decimal data type,
                        > which can handle more digits on both sides of the decimal point, for all
                        > money variables and calculations. Decimal is also directly supported by the
                        > common language runtime."
                        >
                        >
                        > after a small search
                        >
                        > http://msdn.microsoft.com/library/de...ypechanges.asp
                        >
                        >
                        > after some googling i found that some people recomend a 64 bit integer to
                        > hold currency values
                        >[/color]

                        The decimal data type is a 64-bit integer internally.

                        --
                        Tom Shelton [MVP]

                        Comment

                        Working...