为什么“Dim instance As New Timer”不正确? [英] Why is "Dim instance As New Timer" not correct?

查看:57
本文介绍了为什么“Dim instance As New Timer”不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用它时


Dim实例作为新计时器


我收到错误:错误1重载解析失败,因为无法访问

''新''接受这个数量的参数。


然而,在Timer的帮助部分(在VB 2005中),这正是语法

显示。我也试过了:


昏暗的实例作为Timer =新的计时器


这也给出了同样的错误。


-

Anil Gupte
www.keeninc。网
www.icinema.com
www.wizo.tv

解决方案

10月13日,1:34 * pm,Anil Gupte / iCinema.com < anil -l ... @ icinema.com>

写道:


当我使用它时


昏暗实例作为新计时器


我收到错误:错误1重载解析失败,因为无法访问

''新''接受此参数的数量。


然而,在Timer的帮助部分(在VB 2005中),这正是显示的语法

。我也试过了:


昏暗的实例作为Timer =新的计时器


这也给出了同样的错误。


-

Anil Guptewww.keeninc.netwww.icinema.comwww.wizo.tv



我想你是引用System.Threading.Timer,因此你得到了

错误,因为System.Threading下的Timer对象不接受空的
构造函数,请参阅构造函数重载列表:
http://msdn.microsoft.com/en-us/libr...r(VS.80)..aspx


如果要实例化System.Timers.Timer,你可以使用它与

空构造函数来初始化Timer对象:


Dim instance As New System.Timers.Timer
http://msdn.microsoft .COM / EN-US /溴化锂... mer.tim er.aspx


希望这会有所帮助,


OnurGüzel


< blockquote>" Anil Gupte / iCinema.com" < a ******* @ icinema.comschrieb


当我使用它时


Dim instance As New计时器


我收到错误:错误1重载解析失败,因为没有

可访问''新''接受这个数量的参数。


然而,在Timer的帮助部分(在VB 2005中),这正是显示的

语法。我也试过了:


Dim instance As Timer = New Timer


,这也给出了同样的错误。



哪种计时器?不仅有一个。

- System.Windows.Forms.Timer

- System.Timers.Timer

- System.Threading.Timer


如果你使用后者,它没有无参数的结构,

这解释了错误信息。导入另一个命名空间或使用完整的

限定名称来指定其他一个计时器。如果它们不是可用的b $ b,那么就可以设置对包含组件的引用。

Armin


Thanx,我会试试。


-

Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv

" Armin Zingler" < az ******* @ freenet.dewrote in message

news:%2 **************** @ TK2MSFTNGP06.phx.gbl ...


" Anil Gupte / iCinema.com" < an ******* @ icinema.comschrieb


>当我使用这个

Dim实例作为新计时器

我收到错误:错误1重载解析失败,因为没有
可访问''新''接受这个数量的参数。

然而,在帮助部分中Timer(在VB 2005中)这正是显示的
语法。我也试过了:

Dim实例作为Timer = New Timer

并且给出了同样的错误。



哪种计时器?不仅有一个。

- System.Windows.Forms.Timer

- System.Timers.Timer

- System.Threading.Timer


如果你使用后者,它没有无参数的结构,

这解释了错误信息。导入另一个命名空间或使用完整的

限定名称来指定其他一个计时器。如果它们不是可用的b $ b,那么你可以设置对包含组件的引用。


Armin



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

解决方案

On Oct 13, 1:34*pm, "Anil Gupte/iCinema.com" <anil-l...@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 Guptewww.keeninc.netwww.icinema.comwww.wizo.tv

I think you''re referring to System.Threading.Timer, hence you get the
error because Timer object under System.Threading doesn''t accept empty
constructor, see constructor overload list here:
http://msdn.microsoft.com/en-us/libr...r(VS.80)..aspx

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

Dim instance As New System.Timers.Timer
http://msdn.microsoft.com/en-us/libr...mer.timer.aspx

Hope this helps,

Onur Güzel


"Anil Gupte/iCinema.com" <an*******@icinema.comschrieb

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.Timer
- System.Threading.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


Thanx, I will try that.

--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

"Anil Gupte/iCinema.com" <an*******@icinema.comschrieb

>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.Timer
- System.Threading.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



这篇关于为什么“Dim instance As New Timer”不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆