Option Strict的后期绑定错误? [英] Late binding errors with Option Strict ?
问题描述
大家好,
我有以下问题:我的程序运行正常,但是当我在表单顶部添加选项
strict时,以下子程序失败并显示错误选项
strict不允许后期绑定。我该怎么办?
Public Sub MyMnuHandler(ByVal sender As Object,ByVal e As System.EventArgs)
如果sender.checked = True那么发件人。 checked = False Else sender.checked = True
End Sub
Hi all,
I have the following problem: my program works fine, but when I add option
strict at the top of the form, the following sub fails with an error that option
strict does not allow late binding. What should I do?
Public Sub MyMnuHandler(ByVal sender As Object, ByVal e As System.EventArgs)
If sender.checked = True Then sender.checked = False Else sender.checked = True
End Sub
推荐答案
选项Strict ON是一个好主意,但会涉及更多的工作。
您需要将发件人转换为适当的类型
尝试
dim src为MenuItem = CType(sender,MenuItem)
src.checked = not src.checked
hth ,
艾伦。
Option Strict ON is a great idea but will involve a touch more work.
You need to cast the sender to the appropriate type
Try
dim src as MenuItem = CType(sender, MenuItem)
src.checked = not src.checked
hth,
Alan.
不要使用严格的选项
Tom
David写道:
Don''t use option strict
Tom
David wrote:
大家好,
我有以下问题:我的程序运行正常,但是当我添加选项时
严格在表单的顶部,以下sub失败并显示错误选项
严格不允许后期绑定。我该怎么办?
Public Sub MyMnuHandler(ByVal sender As Object,ByVal e As System.EventArgs)
如果sender.checked = True那么sender.checked = False Else sender.checked = True
End Sub
Hi all,
I have the following problem: my program works fine, but when I add option
strict at the top of the form, the following sub fails with an error that option
strict does not allow late binding. What should I do?
Public Sub MyMnuHandler(ByVal sender As Object, ByVal e As System.EventArgs)
If sender.checked = True Then sender.checked = False Else sender.checked = True
End Sub
" David" <在******************** @ yahoo.co.uk>在留言中写道:大江************** @ TK2MSFTNGP15.phx.gbl ...
"David" <in********************@yahoo.co.uk> wrote in message news:Oe**************@TK2MSFTNGP15.phx.gbl...
大家好,我有以下问题:我的程序工作正常,但是当我在表单顶部添加选项
strict时,以下子程序失败并显示错误选项
strict不允许后期绑定。我该怎么办?
Public Sub MyMnuHandler(ByVal sender As Object,ByVal e As System.EventArgs)
如果sender.checked = True那么sender.checked = False Else sender.checked = True
End Sub
Hi all,
I have the following problem: my program works fine, but when I add option
strict at the top of the form, the following sub fails with an error that option
strict does not allow late binding. What should I do?
Public Sub MyMnuHandler(ByVal sender As Object, ByVal e As System.EventArgs)
If sender.checked = True Then sender.checked = False Else sender.checked = True
End Sub
您需要将''sender''转换为正确的类型。
CType(发件人,MenuItem),Checked =非CType(发件人,MenuItem)。查看
-
Al Reid
You need to cast ''sender'' to the correct type.
CType(sender, MenuItem),Checked = Not CType(sender, MenuItem).Checked
--
Al Reid
这篇关于Option Strict的后期绑定错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!