Trying to find how to tell VB to use COM object. In C# it is quite simple - select Add Reference - > COM -> select library you need and add simple code like this:
AMyClass c = new AMyClass();
int i;
c.A_Myfnc(out i);
It works fine in C#.
How to make the same in VB?
I stuck in when I was trying to add COM object reference in VB 2012. Where is exact place where I can add my OCX reference? I was trying to ad component to toolbox, but in could not find my component in COM tab list. My COM is not visual.
Then I tried to use VB 2013. There I found that I can add reference in solution explorer like in C# and I see my component registered. That is fine, but what is syntax of creating COM object in VB?
Related
I have build a COM object via ATL, to use compiled C++ in VBA. My type library is (say) "MyObjLib", and the object is "MyObj".
If I use the Object Browser in VBA, all looks good: it shows me the Library as MyObjLib, and within that I see a class MyObj as a member of the library.
If, in VBA, I include this library through the References menu, I can write:
Dim obj as MyObj
Set obj = new MyObj
and it all works fine. However if I try:
Dim obj as Object
Set obj = CreateObject("MyObjLib.MyObj")
it fails with "Runtime Error 429: ActiveX component can't create object."
This is unfortunate as I now want to use the COM object from Python. Any ideas what I am missing?
Thanks for the comments. I spent some time searching my C++ code for the ProgId. Then I stumbled across another SO answer, about someone who had left the ProgId field blank in the ATL Simple COM object Wizard ... which is exactly what I had done! Hence I had never registered the ProgId for the class (and hence no entry in HKCR in the Registy).
I created another project using the Wizard, this time entering a ProgID and copied the syntax from the .rgs file in the new project to my existing one.
Hey presto, CreateObject() works fine now.
I have visual c++ .dll file which I have added as the reference in VB.Net project. That created Interop.mydlllib.dll.
Now I want to use the function having three parameters from dll inside my one function.
How to call this VC++ dll function inside my VB.Net function.
I'm very new to VB.Net, so any help is appreciated... :)
(I searched on the internet and tried the ways suggested there...but still error ... :( )
If you've referenced a Dll inside a VB project, then you will simply need to call it from it's namespace.
I.e. inside the C++ project there will be something (Probably the application/dll name) that it will register itself under.
From here, you simply need to start typing for intellisense to kick in and you'll see the name of your Dll listed in the dropdown list. Select that name and you should see your function name that you'll be able to call.
I have this code in vb.net
dim WebBrowser = New SHDocVw.InternetExplorer
Obviously this code requires some library. Which one?
The code uses to work. I remove all references, and I forget which one I should add.
This page shows https://msdn.microsoft.com/en-us/library/ms970672.aspx that it should be microsoft.internetcontrol
However, I cannot find microsoft.internetcontrol among list of references.
Based on the following, you need to add the Microsoft Internet Controls COM object (not .NET assembly) for it to work.
In Visual Studio 2015:
I have a project that I have converted from VB6 to .NET, using Visual Studio 2008 with the framework 2.0. In VB6 you can call a PopupMenu like so:
Call Me.PopupMenu(mnuEstimating)
I tired to use the same code in .NET but I get the error:
'PopupMenu' is not a member of 'frmEstimatePriority'.
I have looked around on the web and have seen ContextMenuStrip being used in place of this. I would like not to have to add another/new object to the form designer if I don't have to. Is there another easier option besides ContextMenuStrip?
Can someone please tell me how to open a PopupMenu in VB.NET?
Assuming the form has a ContextMenuStrip control with menu items, try:
Me.ContextMenuStrip.Show(MousePosition)
Thanks a lot for the received answer.the following is brief description of how my project works.
GUI is used to collect information from User and validates.have got dll named controlclass that pass input data from GUI to Business logic DLL.this dLL connect to the database and saves data.after that,it disconnected and takes the results to the control dll,then to GUI which interprets if the input data was successful or not.Is there a tool that can be used to convert VB6 GUI to .net web forms?
am not familiar to vb.net.how do you create reference to vb6 dll or COM from vb.net?
In order to create a reference to a VB6 COM object from VB.NET:
Select Project>[Your Project] Properties OR Double Click on My Project in the Solution Explorer window
Select the References tab
Click Add
Select the COM tab
Select the component you require
You will notice that Visual Studio will creates an Interop assembly which handles the interfacing to the COM object for you.
From that point on accessing the COM object is the same as VB6
Dim obj as New MyObject
obj.DoSomething
'etc
Set obj = nothing