Why is "Dim instance As New Timer" not correct?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anil Gupte/iCinema.com

    Why is "Dim instance As New Timer" not correct?

    When I use this

    Dim instance As New Timer

    I get the error: Error 1 Overload resolution failed because no accessible
    'New' accepts this number of arguments.

    Yet, in the help section for Timer (in VB 2005) this is exactly the syntax
    shown. I also tried:

    Dim instance As Timer = New Timer

    and that gives the same error.

    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving





  • kimiraikkonen

    #2
    Re: Why is "Dim instance As New Timer" not correct?

    On Oct 13, 1:34 pm, "Anil Gupte/iCinema.com" <anil-l...@icinema.co m>
    wrote:
    When I use this
    >
    Dim instance As New Timer
    >
    I get the error: Error 1 Overload resolution failed because no accessible
    'New' accepts this number of arguments.
    >
    Yet, in the help section for Timer (in VB 2005) this is exactly the syntax
    shown. I also tried:
    >
    Dim instance As Timer = New Timer
    >
    and that gives the same error.
    >
    --
    Anil Guptewww.keenin c.netwww.icinem a.comwww.wizo.t v
    I think you're referring to System.Threadin g.Timer, hence you get the
    error because Timer object under System.Threadin g doesn't accept empty
    constructor, see constructor overload list here:
    Gain technical skills through documentation and training, earn certifications and connect with the community


    If you want to instantiate System.Timers.T imer, you can use it with
    empty constructor to initialize Timer object:

    Dim instance As New System.Timers.T imer
    Generates an event after a set interval, with an option to generate recurring events.


    Hope this helps,

    Onur Güzel

    Comment

    • Armin Zingler

      #3
      Re: Why is &quot;Dim instance As New Timer&quot; not correct?

      "Anil Gupte/iCinema.com" <anil-list@icinema.co mschrieb
      When I use this
      >
      Dim instance As New Timer
      >
      I get the error: Error 1 Overload resolution failed because no
      accessible 'New' accepts this number of arguments.
      >
      Yet, in the help section for Timer (in VB 2005) this is exactly the
      syntax shown. I also tried:
      >
      Dim instance As Timer = New Timer
      >
      and that gives the same error.
      Which kind of Timer? There is not only one.
      - System.Windows. Forms.Timer
      - System.Timers.T imer
      - System.Threadin g.Timer

      If you use the latter one, it does not have a parameterless concstructor,
      which explains the error message. Import another namespace or use the full
      qualified name to specify one of the other timers. If they are not
      available, ouy ahve to set a reference to the containing assembly.


      Armin

      Comment

      • Anil Gupte/iCinema.com

        #4
        Re: Why is &quot;Dim instance As New Timer&quot; not correct?

        Thanx, I will try that.

        --
        Anil Gupte
        Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



        "Armin Zingler" <az.nospam@free net.dewrote in message
        news:%23WD6pLSL JHA.1500@TK2MSF TNGP06.phx.gbl. ..
        "Anil Gupte/iCinema.com" <anil-list@icinema.co mschrieb
        >When I use this
        >>
        >Dim instance As New Timer
        >>
        >I get the error: Error 1 Overload resolution failed because no
        >accessible 'New' accepts this number of arguments.
        >>
        >Yet, in the help section for Timer (in VB 2005) this is exactly the
        >syntax shown. I also tried:
        >>
        >Dim instance As Timer = New Timer
        >>
        >and that gives the same error.
        >
        Which kind of Timer? There is not only one.
        - System.Windows. Forms.Timer
        - System.Timers.T imer
        - System.Threadin g.Timer
        >
        If you use the latter one, it does not have a parameterless concstructor,
        which explains the error message. Import another namespace or use the full
        qualified name to specify one of the other timers. If they are not
        available, ouy ahve to set a reference to the containing assembly.
        >
        >
        Armin

        Comment

        • Anil Gupte/iCinema.com

          #5
          Re: Why is &quot;Dim instance As New Timer&quot; not correct?

          Thanx. This brings up a question I was going to ask next anyway. What is
          the best way to set up a Timer that does not hog the entire CPU? I assume
          that is the System.Threadin g.Timer with a priority set to Normal or
          something like that? I was going to instantiate a Timer and then cacll it
          from a Thread. But I guess System.Threadin g.Timer will be better. Are
          there some good examples of usage in terms of controlling some processes (I
          want to be able to monitor a process from my Timer and then pause it and
          restart it as needed).

          Thanx,
          --
          Anil Gupte
          Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



          "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
          news:a3ed2d79-32e7-43db-a627-f9f0b92c9fb9@s5 0g2000hsb.googl egroups.com...
          On Oct 13, 1:34 pm, "Anil Gupte/iCinema.com" <anil-l...@icinema.co m>
          wrote:
          When I use this
          >
          Dim instance As New Timer
          >
          I get the error: Error 1 Overload resolution failed because no accessible
          'New' accepts this number of arguments.
          >
          Yet, in the help section for Timer (in VB 2005) this is exactly the syntax
          shown. I also tried:
          >
          Dim instance As Timer = New Timer
          >
          and that gives the same error.
          >
          --
          Anil Guptewww.keenin c.netwww.icinem a.comwww.wizo.t v
          I think you're referring to System.Threadin g.Timer, hence you get the
          error because Timer object under System.Threadin g doesn't accept empty
          constructor, see constructor overload list here:
          Provides a mechanism for executing a method on a thread pool thread at specified intervals. This class cannot be inherited.


          If you want to instantiate System.Timers.T imer, you can use it with
          empty constructor to initialize Timer object:

          Dim instance As New System.Timers.T imer
          Generates an event after a set interval, with an option to generate recurring events.


          Hope this helps,

          Onur Güzel


          Comment

          • Cor Ligthert[MVP]

            #6
            Re: Why is &quot;Dim instance As New Timer&quot; not correct?

            Anil,

            As long as it is not for a service or to be used in an extra thread use the

            System.Forms.Ti mer, that is simple the best but does not work in the above
            situations

            Cor

            "Anil Gupte/iCinema.com" <anil-list@icinema.co mschreef in bericht
            news:u5keFOWLJH A.3764@TK2MSFTN GP04.phx.gbl...
            Thanx. This brings up a question I was going to ask next anyway. What is
            the best way to set up a Timer that does not hog the entire CPU? I assume
            that is the System.Threadin g.Timer with a priority set to Normal or
            something like that? I was going to instantiate a Timer and then cacll it
            from a Thread. But I guess System.Threadin g.Timer will be better. Are
            there some good examples of usage in terms of controlling some processes
            (I want to be able to monitor a process from my Timer and then pause it
            and restart it as needed).
            >
            Thanx,
            --
            Anil Gupte
            Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



            "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
            news:a3ed2d79-32e7-43db-a627-f9f0b92c9fb9@s5 0g2000hsb.googl egroups.com...
            On Oct 13, 1:34 pm, "Anil Gupte/iCinema.com" <anil-l...@icinema.co m>
            wrote:
            >When I use this
            >>
            >Dim instance As New Timer
            >>
            >I get the error: Error 1 Overload resolution failed because no accessible
            >'New' accepts this number of arguments.
            >>
            >Yet, in the help section for Timer (in VB 2005) this is exactly the
            >syntax
            >shown. I also tried:
            >>
            >Dim instance As Timer = New Timer
            >>
            >and that gives the same error.
            >>
            >--
            >Anil Guptewww.keenin c.netwww.icinem a.comwww.wizo.t v
            >
            I think you're referring to System.Threadin g.Timer, hence you get the
            error because Timer object under System.Threadin g doesn't accept empty
            constructor, see constructor overload list here:
            Provides a mechanism for executing a method on a thread pool thread at specified intervals. This class cannot be inherited.

            >
            If you want to instantiate System.Timers.T imer, you can use it with
            empty constructor to initialize Timer object:
            >
            Dim instance As New System.Timers.T imer
            Generates an event after a set interval, with an option to generate recurring events.

            >
            Hope this helps,
            >
            Onur Güzel
            >

            Comment

            • =?Utf-8?B?anAybXNmdA==?=

              #7
              RE: Why is &quot;Dim instance As New Timer&quot; not correct?

              Anil,

              Name your variable something besides "instance." Try TicToc or Timer1.

              FYI: You can't name your variable int, string, class, or return either.
              Understand?

              "Anil Gupte/iCinema.com" wrote:
              When I use this
              >
              Dim instance As New Timer
              >
              I get the error: Error 1 Overload resolution failed because no accessible
              'New' accepts this number of arguments.
              >
              Yet, in the help section for Timer (in VB 2005) this is exactly the syntax
              shown. I also tried:
              >
              Dim instance As Timer = New Timer
              >
              and that gives the same error.
              >
              --
              Anil Gupte
              Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



              >
              >
              >

              Comment

              • Anil Gupte/iCinema.com

                #8
                Re: Why is &quot;Dim instance As New Timer&quot; not correct?

                Umm, I have been programming for longer than you have been using your brain.
                Of course I used different variable names. And BTW, I don't think instance
                is incorrect to use as a variable name. The following are all valid.
                Dim instance As Integer

                Dim instance As String

                Dim instance As Timer

                Dim instance As System.Timers.T imer
                --
                Anil Gupte
                Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving




                "jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
                news:A42E0623-5A1C-4D33-B05F-D5CD5335FE1F@mi crosoft.com...
                Anil,
                >
                Name your variable something besides "instance." Try TicToc or Timer1.
                >
                FYI: You can't name your variable int, string, class, or return either.
                Understand?
                >
                "Anil Gupte/iCinema.com" wrote:
                >
                >When I use this
                >>
                >Dim instance As New Timer
                >>
                >I get the error: Error 1 Overload resolution failed because no accessible
                >'New' accepts this number of arguments.
                >>
                >Yet, in the help section for Timer (in VB 2005) this is exactly the
                >syntax
                >shown. I also tried:
                >>
                >Dim instance As Timer = New Timer
                >>
                >and that gives the same error.
                >>
                >--
                >Anil Gupte
                >www.keeninc.net
                >www.icinema.com
                >www.wizo.tv
                >>
                >>
                >>

                Comment

                • =?Utf-8?B?anAybXNmdA==?=

                  #9
                  Re: Why is &quot;Dim instance As New Timer&quot; not correct?

                  Remind me to never offer any ideas or help to you again.

                  I do not develop in VB.

                  "Anil Gupte/iCinema.com" wrote:
                  Umm, I have been programming for longer than you have been using your brain.
                  Of course I used different variable names. And BTW, I don't think instance
                  is incorrect to use as a variable name. The following are all valid.
                  Dim instance As Integer
                  >
                  Dim instance As String
                  >
                  Dim instance As Timer
                  >
                  Dim instance As System.Timers.T imer
                  --
                  Anil Gupte
                  Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



                  >
                  "jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
                  news:A42E0623-5A1C-4D33-B05F-D5CD5335FE1F@mi crosoft.com...
                  Anil,

                  Name your variable something besides "instance." Try TicToc or Timer1.

                  FYI: You can't name your variable int, string, class, or return either.
                  Understand?

                  "Anil Gupte/iCinema.com" wrote:
                  When I use this
                  >
                  Dim instance As New Timer
                  >
                  I get the error: Error 1 Overload resolution failed because no accessible
                  'New' accepts this number of arguments.
                  >
                  Yet, in the help section for Timer (in VB 2005) this is exactly the
                  syntax
                  shown. I also tried:
                  >
                  Dim instance As Timer = New Timer
                  >
                  and that gives the same error.
                  >
                  --
                  Anil Gupte
                  Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



                  >
                  >
                  >
                  >
                  >
                  >

                  Comment

                  • Anil Gupte/iCinema.com

                    #10
                    Re: Why is &quot;Dim instance As New Timer&quot; not correct?

                    It is very obvious that you don't develop in VB!!!!

                    --
                    Anil Gupte
                    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



                    "jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
                    news:A62249B7-4F36-42CD-A25D-A4402651F7CD@mi crosoft.com...
                    Remind me to never offer any ideas or help to you again.
                    >
                    I do not develop in VB.
                    >
                    "Anil Gupte/iCinema.com" wrote:
                    >
                    >Umm, I have been programming for longer than you have been using your
                    >brain.
                    >Of course I used different variable names. And BTW, I don't think
                    >instance
                    >is incorrect to use as a variable name. The following are all valid.
                    >Dim instance As Integer
                    >>
                    >Dim instance As String
                    >>
                    >Dim instance As Timer
                    >>
                    >Dim instance As System.Timers.T imer
                    >--
                    >Anil Gupte
                    >www.keeninc.net
                    >www.icinema.com
                    >www.wizo.tv
                    >>
                    >"jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
                    >news:A42E062 3-5A1C-4D33-B05F-D5CD5335FE1F@mi crosoft.com...
                    Anil,
                    >
                    Name your variable something besides "instance." Try TicToc or Timer1.
                    >
                    FYI: You can't name your variable int, string, class, or return either.
                    Understand?
                    >
                    "Anil Gupte/iCinema.com" wrote:
                    >
                    >When I use this
                    >>
                    >Dim instance As New Timer
                    >>
                    >I get the error: Error 1 Overload resolution failed because no
                    >accessible
                    >'New' accepts this number of arguments.
                    >>
                    >Yet, in the help section for Timer (in VB 2005) this is exactly the
                    >syntax
                    >shown. I also tried:
                    >>
                    >Dim instance As Timer = New Timer
                    >>
                    >and that gives the same error.
                    >>
                    >--
                    >Anil Gupte
                    >www.keeninc.net
                    >www.icinema.com
                    >www.wizo.tv
                    >>
                    >>
                    >>
                    >>
                    >>
                    >>

                    Comment

                    • Cor Ligthert[MVP]

                      #11
                      Re: Why is &quot;Dim instance As New Timer&quot; not correct?

                      Anil,

                      But it seems that you don't read the answers you get. Are you sure you are
                      creating a Service or somthing like that.

                      As I wrote earlier in this thread, the System.Timers.T imer is only for
                      Services or thinks like that.

                      Normally there is a better one for this. (There are 3 timers available)

                      Cor

                      "Anil Gupte/iCinema.com" <anil-list@icinema.co mwrote in message
                      news:OzAbgqvLJH A.4600@TK2MSFTN GP06.phx.gbl...
                      Umm, I have been programming for longer than you have been using your
                      brain. Of course I used different variable names. And BTW, I don't think
                      instance is incorrect to use as a variable name. The following are all
                      valid.
                      Dim instance As Integer
                      >
                      Dim instance As String
                      >
                      Dim instance As Timer
                      >
                      Dim instance As System.Timers.T imer
                      --
                      Anil Gupte
                      Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



                      >
                      "jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
                      news:A42E0623-5A1C-4D33-B05F-D5CD5335FE1F@mi crosoft.com...
                      >Anil,
                      >>
                      >Name your variable something besides "instance." Try TicToc or Timer1.
                      >>
                      >FYI: You can't name your variable int, string, class, or return either.
                      >Understand?
                      >>
                      >"Anil Gupte/iCinema.com" wrote:
                      >>
                      >>When I use this
                      >>>
                      >>Dim instance As New Timer
                      >>>
                      >>I get the error: Error 1 Overload resolution failed because no
                      >>accessible
                      >>'New' accepts this number of arguments.
                      >>>
                      >>Yet, in the help section for Timer (in VB 2005) this is exactly the
                      >>syntax
                      >>shown. I also tried:
                      >>>
                      >>Dim instance As Timer = New Timer
                      >>>
                      >>and that gives the same error.
                      >>>
                      >>--
                      >>Anil Gupte
                      >>www.keeninc.net
                      >>www.icinema.com
                      >>www.wizo.tv
                      >>>
                      >>>
                      >>>
                      >
                      >

                      Comment

                      • Anil Gupte/iCinema.com

                        #12
                        Re: Why is &quot;Dim instance As New Timer&quot; not correct?

                        I have been reading my messages and am working on implementing
                        System.Threadin g.Timer but haven't got around to it. I was just dumping on
                        someone who was being rude and obnoxious.

                        Thanx,
                        --
                        Anil Gupte
                        Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



                        "Cor Ligthert[MVP]" <Notmyfirstname @planet.nlwrote in message
                        news:%239st$m6L JHA.3744@TK2MSF TNGP05.phx.gbl. ..
                        Anil,
                        >
                        But it seems that you don't read the answers you get. Are you sure you are
                        creating a Service or somthing like that.
                        >
                        As I wrote earlier in this thread, the System.Timers.T imer is only for
                        Services or thinks like that.
                        >
                        Normally there is a better one for this. (There are 3 timers available)
                        >
                        Cor
                        >
                        "Anil Gupte/iCinema.com" <anil-list@icinema.co mwrote in message
                        news:OzAbgqvLJH A.4600@TK2MSFTN GP06.phx.gbl...
                        >Umm, I have been programming for longer than you have been using your
                        >brain. Of course I used different variable names. And BTW, I don't think
                        >instance is incorrect to use as a variable name. The following are all
                        >valid.
                        >Dim instance As Integer
                        >>
                        >Dim instance As String
                        >>
                        >Dim instance As Timer
                        >>
                        >Dim instance As System.Timers.T imer
                        >--
                        >Anil Gupte
                        >www.keeninc.net
                        >www.icinema.com
                        >www.wizo.tv
                        >>
                        >"jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
                        >news:A42E062 3-5A1C-4D33-B05F-D5CD5335FE1F@mi crosoft.com...
                        >>Anil,
                        >>>
                        >>Name your variable something besides "instance." Try TicToc or Timer1.
                        >>>
                        >>FYI: You can't name your variable int, string, class, or return either.
                        >>Understand?
                        >>>
                        >>"Anil Gupte/iCinema.com" wrote:
                        >>>
                        >>>When I use this
                        >>>>
                        >>>Dim instance As New Timer
                        >>>>
                        >>>I get the error: Error 1 Overload resolution failed because no
                        >>>accessible
                        >>>'New' accepts this number of arguments.
                        >>>>
                        >>>Yet, in the help section for Timer (in VB 2005) this is exactly the
                        >>>syntax
                        >>>shown. I also tried:
                        >>>>
                        >>>Dim instance As Timer = New Timer
                        >>>>
                        >>>and that gives the same error.
                        >>>>
                        >>>--
                        >>>Anil Gupte
                        >>>www.keeninc.net
                        >>>www.icinema.com
                        >>>www.wizo.tv
                        >>>>
                        >>>>
                        >>>>
                        >>
                        >>
                        >

                        Comment

                        Working...