Visual Basic 6
Visual Basic is a third-generation event-driven programming language and Integrated Development Environment (IDE) from Microsoft for its COM programming model. Programming in VB is a combination of visually arranging components or controls on a form, specifying attributes and actions for those components and writing additional lines of code for more functionality.
It's mainly for thick client applications.
The application is targeted towards Windows registries, not assemblies.
.Net
A Microsoft operating system platform that incorporates applications, a suite of tools and services and a change in the infrastructure of the company's Web strategy. The .NET Framework supports building and running of the next gen of applications and XML Web services.
It will support both thick and thin client applications.
The applications are targeted towards assembly.
Use .Net components to VB6 applications
.Net COM enables component
Build the component as a COM visible one.
Code part
- [ComVisible(true),
- GuidAttribute("137AD71F-4657-4362-B9E4-C6D734F1F530")]
- [InterfaceType(ComInterfaceType.InterfaceIsDual)]
- public interface IGetMyString
- {
- string GetMyString();
- }
- [ComVisible(true),
- GuidAttribute("89BB4535-5A89-43a0-89C5-19A4697E5C5C")] [ClassInterface(ClassInterfaceType.None)]
- public class Class1 : IGetMyString
- {
- string GetMyString()
- {
- }
- }
Ensure that signing is done.
Build
Now build the component.
In the Bin folder you will get a .dll, a .tlb and a .pdb file.
If suppose the tlb is not available then use the following command line in your Visual Studio command prompt.
- tlbexp myTest.dll /out: myTest.tlb
Incorporate tlb file into VB6 environmentRun with the default command line. Regasm does the following two main things to register an assembly:
- It creates COM registration entries that register the Class Guids. These are the entries in HKCR\CLSID\{Your Guid} that allow COM client programs to find your classes and your assembly, either by ProgId or by your Class Guid.
- It creates type library information from the assembly's metadata and registers that type library information. These registry entries are in HKCR\Interface\{Your interface Guid}.
Refer the .tlb file in the VB6 developer tool as the reference.
Create the instance in the VB6 file. Now you can access the features.