[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
vbcreatecom

How do I create A Visual Basic COM Component?

Create a new project. Choose Active X DLL as the project type Uncheck Upgrade controls from Project options.

Add any references that you might need, such as ADO for database use. More importantly Add the COM+ reference (Windows 2k)

Change the Project name from Project1 to something that suits the project. For this example lets change it to:

PrjExample

Change the class name from the default also to something more meaningful. Again lets follow the scheme and change it to:

ClsExample

With the foundations set. Lets create a Function to test our DLL.

Public Function ExampleFunc(ByVal ExampleString, ByVal RtnStr) As Integer
Rtnstr = ExampleString & “ “ & “ “ Is Passed back to you “ & VBCrlf
End Function


Compile the DLL.

Put VB in Run Mode. (This is the quick way)

Create an ASP with an editor of your choice.

<%@ Language=VBScript %>
<% Option Explicit %>
<HTML>
<HEAD>
Dim objExample
Dim RtnStr
Set objExample = CreateObject("prjExample.clsExample")
</HEAD>
<FORM Method="POST" Action="Example.asp" name=form1>
<BODY>

<%
Call objExample.ExampleFunc(“Text From this page ”,RtnStr)
Response.Write(“RtnStr”)
Set objExample = Nothing
%>
</BODY>
</FORM
</HTML>


Save this file on your Web Server directory and open it with a browser to see the result.

VB FAQ



last edited (March 19, 2004) by leeos, Number of views: 2467, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.