问题描述
大家好,
我有以下问题:我的程序运行正常,但是当我在表单顶部添加选项
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
推荐答案
您需要将''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的后期绑定错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!