Using an old VB6 ActiveX Control or Code Component in VB.NET

Georgen

Active member
Joined
Jan 22, 2005
Messages
34
Hi. The other day I started VB.NET and tried to Add a reference to a COM component, a few controls I created in VB6... then...

1. It didnt show a decent error, it just did nothing.
2. After checking all the screen I saw in a little dockable window in the low part of the IDE and error about some error with oleaut.

Lets put it this way. How can I use and old ActiveX component created with VB6 (in my case) with VB.NET? :confused:
 
Hi again. Just to mention... First, There is no real NEED of doing this, its just that I wanted to know if it was possible and Second, I supposed someone will have that problem with a very big and complicated component that dont want to recreate. Well thanks for anything.
 
You should be able to drag and drop ActiveX controls onto your .Net Form in the Designer as with any control. It will work the the COM Interop and so will run a bit slower, and its generally better to use a .Net control instead of a COM ActiveX control... but it should work fine.

Which ActiveX control are you trying to use? It sounds like it might be a control that comes with VB6?? I think it would be better to use the equivalent .Net control instead. Which control is it and maybe we can help...
 
Well it is a control a made with Visual Basic 6. It has nothing special, but perhaps I should create a new one with VB6, totally random to test if I have some problem. Ill let you know.

By the way... my VS.NET pre-release, has this great control StripMenu but it has a lot of bugs, I mean the .NET control doesnt work fine! What about it?
 
Ok, so you have your own UserControl that you made with VB6 and wish to use it in VB.Net? I know it doesnt sound like fun to re-do your control from scratch, but it does sound like its worth learning how to make a UserControl in .Net instead and re-make it. Ive never done it myself, but reading about it it looks pretty straight forward, and very parallel to the procedure used in VB6.

If you dont re-do it, I think youre talking about having to register your ActiveX control as well as whatever controls your ActiveX is using? I could be wrong about that, but, yes, at a minimum you could try making a new, very-simple ActiveX control and see if it works. It should, but a complex one may have special issues. Again, Id seriously think about learning how to make a UserControl "the .Net way".

As for the StipMenu control, I dont have any experience with that. You probably should post your question regarding the StripMenu within the .Net General Forum.

Hope this helps!
Mike
 
OK... about the StripMenu Ill find help later... and I sure want to learn the ".NET way"... as I said there is no real need to do this... I just wanted to know if it was possible to share a VB6 COM Object with VB.NET... Thanks.
:)
 
In theory, yes absolutely. The COM Interop makes this possible and generally does so seemlessly. That said, it is still generally best to stay 100% within .Net if that is possible/reasonable, and your custom ActiveX control is not behaving properly. :(

So where you go from here, Im not sure, but my advice would be to re-do it in .Net if that is at all possible/reasonable. If you wish to fix it "in place", I think you have to make sure that your ActiveX control is registered properly as well as the various sub-controls that your ActiveX UserControl is utilizing.

But since it works on VB6, I would guess that they are? So it remains a mystery as to why it would fail in .Net then... but if it is a complex control, as you stated, then it will likely be a lot of work to track down where the COM Interop is failing you here. :(
 
Ok. I agree with you, .NET is the way to go... I just felt curious. You know, my control in VB made extensive use of the Windows API and subclassing the container form of the object, and other cool stuff too. I wonder now. . . (Im not very advanced in .NET) but how much different is programming a UserControl in .NET that what it was in VB6. I understand in VB6 all of it was pure disguised COM, now in .NET im not very sure.
 
I dont really know myself. The basics look pretty much the same, bet I can tell (without ever having actually done it.) As for Subclassing I dont know, probably essentially the same, I would guess, but Ive not gone there, so I just dont know.

As you know, subclassing with a UserControl.OCX in VB6 is a touchy business; either you have to be very careful how you hook and unhook, or probably best to use weak pointers... My guess is that the same exact principles may apply in .Net OCXs. However the built-in .Net UserControl events may be more suitable to simple Hook-until-terminated sort of approach, I just dont know. A lot of .Net has been improved over old VB6, recognizing problems, etc., so they may have made this issue less touchy.

I think youll have to go and give it a try! :)
 
Oh. H e l l Yeah!! It looks very interesting. Actually the whole UserControl programming is great. (I have heard that was Alan Cooper who initially came on with the Idea, what an Idea!!)

Yes .NET adds so many facilities with all those extra events that VB needed subclassing to go around, Im happy about that, I suppose I will need subclassing when a proble arises. Cool by now.

By the way the control Ive bee talking all along is a Splitter Control, just like the one that came with my VS.NET. (well ten-times less cooler)... but anyway I havent been able to make it work. (I should keep trying but forgetting the past and getting to work the new tech sure seems more exciting!!)

Note: Go learn it yourself so you can explain me later. gg (kddin)
 
Ok, just had a look, yeah that Splitter Control does look very cool, eh? :cool:

I will get into UserControls at some point, I just havent gotten to it yet. When Im ready, Ill be bugging you for a lession, I think. ;)
 
Back
Top