Make your own free website on Tripod.com

Classic COM to .NET Interoperability
Building a Classic COM Client using Visual Basic ver 6.0

Gopalan Suresh Raj

Note
To work with any of these samples, you will need the following:
.........................................Microsoft .NET SDK
.........................................Microsoft Visual Studio.NET Beta 2 or higher
.........................................Microsoft Visual Basic ver 6.0

 

Create a simple VB 6.0 Standard EXE project type and set a reference to the new generated QuoteServer type library. Before you add any code, save the entire project.

1. Create a GUI Front-end

A single button will be used to manipulate the .NET Type.

Wait for the picture to load

2. Develop the VB6ClientForm.frm Form

VB6ClientForm.frm
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
VERSION 5.00
Begin VB.Form Form1
   Caption         =   "VB Quote Client"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1
      Caption         =   "Get Quote"
      Height          =   375
      Left            =   1560
      TabIndex        =   1
      Top             =   2040
      Width           =   1455
   End
   Begin VB.TextBox Text1
      Height          =   285
      Left            =   2760
      TabIndex        =   0
      Text            =   "iCommWare"
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label Label2
      Caption         =   "Price in US Dollars is"
      Height          =   375
      Left            =   240
      TabIndex        =   4
      Top             =   1320
      Width           =   2295
   End
   Begin VB.Label Enter
      Caption         =   "Enter Company's Stock Symbol"
      Height          =   375
      Left            =   240
      TabIndex        =   3
      Top             =   720
      Width           =   2295
   End
   Begin VB.Label Label1
      Caption         =   "0"
      Height          =   255
      Left            =   2760
      TabIndex        =   2
      Top             =   1320
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  On Error GoTo Error:

  'Make .NET Type
  Dim object As New QuoteServer.QuoteServer
  Dim interface As IQuoteServer
  Set interface = object


  Label1.Caption = interface.getQuote(Text1.Text)

  GoTo Finish:
  
Error:
  MsgBox Err.Description, , "Error!!!"
  
Finish:
End Sub

 

Classic COM to .NET Interoperability
Developing a Classic COM Server Component using C# and .NET - The QuoteServer Example
Developing a Classic COM Client Application using Visual Basic ver 6.0 to access the QuoteServer - The VB6Client Example
Developing a Managed C++ Client Application which binds to the Server using Early Binding - The QuoteClient Example
Developing a Managed C++ Client Application which binds to the Server using Late Binding - The cppLateBinding Example

 

Download the entire source code as a zip file.

 

click here to go to
My Advanced C#/.NET Tutorial Page...

About the Author...
Gopalan Suresh Raj is a Software Architect, Developer and an active Author. He has co-authored a number of books including "Professional JMS", "Enterprise Java Computing-Applications and Architecture" and "The Awesome Power of JavaBeans". His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia site (http://gsraj.tripod.com/) or mail him at gopalan@gmx.net.

 


Go to the Component Engineering Cornucopia page

This site was developed and is maintained by Gopalan Suresh Raj

This page has been visited times since December 27, 2001.

Last Updated : Dec 27, '01

If you have any questions, comments, or problems regarding this site, please write to me I would love to hear from you.


Copyright (c) 1997-2001, Gopalan Suresh Raj - All rights reserved. Terms of use.

All products and companies mentioned at this site are trademarks of their respective owners.