2
votes

Recently I've been trying to create an activeX control and use it in some vb.net code. After much struggle i created my control in vb6 and generated the ocx file. I've been trying to use it as shown in microsoft docs here but to no avail. On :

myActiveX = New MyActiveXComponent.MyClass()

i keep getting

MyActiveXComponent.MyClass.Private Sub New() is not accessible in this context because it is 'Private'

I can import it to toolbox and use that way but i would prefer not to, im using visual studio 2005. Also i have an ocx which to my supprise i can use both ways(not mine) so i suspect there's something wrong with mine, but i can't figure out what.

1
It looks like you are creating an instance if class called MyClass. Is this a class you have defined in your ocx? - tcarvin
@tcarvin Yes trying to instance an user control in this case MyClass which is contained in the ocx, you can find the source code here support.microsoft.com/en-us/help/315847/…. - chomsk
Is your Sub New private? Perhaps it needs to be Public? - Chris Dunaway
@ChrisDunaway I can't write sub new in vb6 at all, as far as i know New should be inside wrapper generated by interop, and it is looking at object browser, but its inhered from System.Object, where in the other working ocx it's a member of the class, almost as it was a class module. - chomsk

1 Answers

2
votes

You are mixing Classes and Controls up a bit. But in any case, if you want your class to be publicly creatable you need to set the Instancing, and I suggest using MultiUse.

Properties