Types that cannot be Converted from VB6 to .Net
Hi all,
I have an Interface named "IMyInterface" declared in VB6. And I have a user control project in VB6, this user control implements the Interface "IMyInterface".
Now I want to use the user control developed in VB6 in my new .Net Project. So I have added the reference of the VB6 user control in the .Net project, by the way .Net IDE creted the Interop dlls. Now I want to make a call on the VB6 user control through the IMyInterface as my VB6 user control implements the Interface. This IMyInterface has 10 functions, some of them returns basic data types and some of them returns structure/class types.
But, I was warned that not all the types in the VB6 will be successfully converted to the .Net types, some of the types may not get converted. Is that correct? if so what all the data types that will not be converted from VB6 to .Net? what shall I do to get rid of this problem? any related article links?
Thanks,
Benin.
[987 byte] By [
Benin] at [2008-2-14]
I'd have to see your interface to know the specifics, but in general, you want to pass simple types between VB6 and VB.NET. Strings, integers, doubles, etc. Anything more complex, you should consider converting to and from a string.
My Interface has 10 functions,
1) string Function1()
2) object Function2()
3) MyEnum Function3(string s)
4) int Function4(MyClass obj)
etc....
The implementation of Function2 in .Net is as follows..
2) public object Function2()
{
// I have added a reference to a VB6 user control (.ocx file) in my project, Interop dll also available for the ocx
// I am returning a class type(complex type) persent in the control
return MyControl.Command;
}
will there be any problem in converting the VB6 complex type to .Net ?
I belive you are using COM to pass data from the OCX control to the .net world. So you need to stick with simple types (string, int, etc) and classes.
Classes used as a data container work fine, but a user defined TYPE in vb6 will not work with COM. Refer to the documentation on the inner workings of com and you will see the supported types.
yes I am using COM to pass data from ocx Control. shoudnt that be done? is there any other way?
You mentioned Classes used as a data container work fine, but a user defined TYPE in vb6 will not work with COM" what is the difference between "DataContainer" and "User Defined Type"?
any related document link you konw?
you are returning myControl.command as an object. But what is the data type for .Command. It should be a string, int, or class to work with com.
I was tring to tell you the user defined types dont work in com. for example, the VB6 type and sample function below would not work.
public Type MyCommandType
Field1 As Long
Field2 as string
end type
public function Command() as MyCommandType
The line above wont work because com does not support user defined types. It supports types like: string, int, date, and objects.