标签云

微信群

扫码加入我们

WeChat QR Code

I'm having a problem with CreateObject. It keeps telling me it's an undeclared element. Is there some specific reference I need to add?The reference for excel etc are already in it, and don't get any more info from MSDN.Public Function BBANtoBIC(ByVal BBAN As String) As StringDim xd As Objectxd = CreateObject("msxml2.domdocument.4.0")xd.Load("http://www.ibanbic.be/IBANBIC.asmx/BBANtoBIC?value=" & BBAN)Do While xd.readyState <> 4DoEvents()LoopBBANtoBIC = xd.TextEnd Function


There are far more natural ways to interact with XML from .NET than using old COM components. There are multiple namespaces dedicated to it. I'm sure if you searched for .NET XML <actual task> you'd find some far more idomatic code.

2019年05月24日39分34秒

This piece is a part I need to use from my boss, because it's a part in our application, so I can't change it just like that.

2019年05月24日39分34秒

Else I would like some suggestions, I'm new in VB.

2019年05月24日39分34秒

On which line you have undeclared element? I am getting "Cannot create ActiveX component" on xd = ...

2019年05月24日39分34秒

Actually since that is all self contained in a function which returns a string, you CAN use a good NET XML method without changing anything else in the project.

2019年05月24日39分34秒

That was the problem I guess, maybe you can help me with the following error I got for CreateObject: "CreateObject cannot be used to create instances of classes in Visual Basic unless those classes are explicitly exposed as COM components."

2019年05月24日39分34秒

Marijke I am not able to reproduce the exception. But it seems that you are either really trying to create not explicitly exposed class or the registry information for the class is corrupt. You should be able to see record in registry e.g.Msxml2.DOMDocument.6.0 is in HKCR\CLSID\{88d96a05-f192-11d4-a65f-0040963251e5}. I would compare records with register in other computer or try to reregister .dll (%SystemRoot%\System32\msxml6.dll). I can also be some combination of x86 and x64 architectures.To find what is going on more detailed information is necessary.

2019年05月23日39分34秒