Groups | Blog | Home
all groups > vb.net upgrade > june 2006 >

vb.net upgrade : VARIANT/VT_ERROR in VB.Net


Thomas Baier
6/12/2006 12:00:00 AM
x-post microsoft.public.dotnet.framework.interop,
microsoft.public.dotnet.vb.upgrade
fup to: microsoft.public.dotnet.framework.interop

Hi,

I'm getting an array of VARIANTs from a COM server. This array contains
different VARIANT types, e.g. VT_I4 and also VT_ERROR.

How can I handle these VT_ERROR values correctly in VB.NET? I'm a bit
confused about the values I get. Sometimes the VT_ERROR is converted to
VT_I4 (which should be the case according to the documentation) and
sometimes I even get a boolean value).

What I need is the real SCODE from the VARIANT. One application (COM server)
handling things like this is Microsoft Excel. Cell errors are transferred as
VT_ERROR.

Its quite easy to create VARIANTs with VT_ERROR type using
System.Runtime.Interop.ErrorWrapper, but what I need is a way to interpret
the VT_ERRORs correctly I get from the COM server.

Of course, in VB6 this can be done using CVErr()...

Best wishes from Austria,
Thomas
AddThis Social Bookmark Button