First of all, I apologise for asking a Visual Basic question here . It's really not my choice to use this damned thing, sigh. VB is such a pile of crap compared to Delphi. Anyway, here's my problem...

I've been asked to write an ActiveX control for an existing system. The ActiveX DLL I'll be writing is an extension to this system. The user (a GP) will search for patients and then select one from a list. When they select a patient, a separate window appears with a tabbed control (dunno whether it's an old tab control, page control, or whatever at the moment). The ActiveX control will be found by the system and will appear as a separate tab on this window.

I have to chuck a web browser onto this separate tab so that the user has access to a browser within the system. It'll have to deal with authentication and other nonsense, but that's in the future.

The above is fine, I think. The people writing the system gave me an example project that seems to add a blank tab fine. The trouble is that this doesn't work very nicely when I add stuff to it .

At the moment I want (no, I need) a webbrowser component (in "Microsoft Internet Controls", shdocvw.dll I think) for what I have to do later. I've managed to create this in code (using the wonderful syntax "set webby = controls.add("Shell.Explorer.2", "webby")". The thing displays and it appears to work, except that the system gives a runtime error 216 when closing down. This error _only happens_ when I try to use the damned web browser (e.g."webby.navigate("http://www.whereever.com").

I've narrowed it down slightly. If I don't select anything on the tab then it's okay -- as long as the focus stays on the tab itself. If I select text in a textbox with the mouse and close the window, I get an access violation and then the program immediately vanishes (due to vb's extemely brittle nature). If I select the web browser, or use its .navigate method, then it seems to work... except that it gives a runtime error 216 when the program is closed for good (not immediately in other words).

AAAAAAAARRRRGGGHHH! I hate VB more than ever - it's so f'cking limiting. Yuck.

Anyway, does anyone have experience with ActiveX controls and/or the web browser component in vb? Can anyone solve the mystery of why it falls over so readily?