Once the assembly is registered and properly installed, the types defined within the assembly can be used from COM as though they were normal COM types. Now you can create a simple VB 6 Standard EXE project type and as I already said confirm whether you set a reference to the new generated type Library. Place this code in the code section and now you see the usage of our .NET type in Classic COM.
Private Sub Command1_Click()
Dim a As New Calculator
MsgBox a.Add(100, 100), vbInformation, "ADDITION
(100,100)"
MsgBox a.GetType, vbInformation, "INFORMATION-TYPE"
MsgBox a.Hello("India"), vbInformation, "STRING"
MsgBox a.Subtract(100, 1), vbInformation, "SUBTRACTION(100-1)"
Dim i As Imuldiv'INTERFACE
Set i = a
MsgBox i.Multiply(100, 100), vbInformation, "MULTIPLICATION(100*100)"
MsgBox i.Division(100, 100), vbInformation, "DIVISION(100/100)"
End Sub
Summary
A lot of companies have spent a great amount of money and time in COM components. With introduction of .NET people are worried about the future of COM. Microsoft has recognized this and provide means to use classic COM components in .NET code and vice versa.
Comments