小编unk*_*nse的帖子

VB中的后期绑定和类型问题

我正在尝试运行我最初使用Visual Studio通过另一个不允许后期绑定的应用程序创建的代码,不幸的是这个选项无法更改.我对编程很新,并努力解决这个问题.这是我在调用代码阶段使用的代码:

Dim objIEShell As Object = CreateObject("Shell.Application")
Dim objIEShellWindows As Object = objIEShell.Windows
Dim objIEWin As Object
For Each objIEWin In objIEShellWindows
    If InStr(objIEWin.LocationURL,"google")>0 Then
        objIEWin.Quit
        objIEWin = Nothing
    End If
Next
Run Code Online (Sandbox Code Playgroud)

该代码只是在URL中使用"google"关闭所有Internet Explorer实例.这是我在尝试编译时得到的错误消息:

Message: Error compiling code
error BC30574: Option Strict On disallows late binding. At line 2
error BC32023: Expression is of type 'Object', which is not a collection type. At line 4
Run Code Online (Sandbox Code Playgroud)

从研究我迄今所做我认识的第一个错误消息,第2行是objIEShell和Windows之间的方法类型的差异做.我想我必须objIEShell像这样转换CType(objIEShell,?),但我不知道.Windows方法的类型或如何找到它.此外,任何关于如何修复第二个错误的见解都将受到极大的赞赏,因为我不知道从哪一个开始.

vb.net types casting compiler-errors late-binding

5
推荐指数
1
解决办法
683
查看次数

标签 统计

casting ×1

compiler-errors ×1

late-binding ×1

types ×1

vb.net ×1