Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Java ASP Components Building
     [next Lesson]  VB: Registering Component

Simple VB Component by Charles Carroll

This is a very simple component written in Visual Basic. You can create it by

  • making a new "Active-X DLL" project
  • under the Project; References menu, you must activate the "Microsoft Active Server Pages" library otherwise it won't recognize the response object and won't compile.
  • The project name ==>   charlescarroll
    The class name   ==>   simplecomponent

Here is the Visual Basic source code for the component:
   filename=/learn/test/charlescarrollsimplecomponent.cls

<Test Script Below>


VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "simpleComponent"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' projectname =charlescarroll
' classname   =simplecomponent
Private ASPresponse As response
Public Sub onstartpage(sc As ScriptingContext)
      Set ASPresponse = sc.response()
End Sub
Public Sub hello()
       ASPresponse.Write "Hello"
End Sub
Public Sub goodbye()
       ASPresponse.Write "Goodbye"
End Sub

Now it is invoked on an ASP page with the following code:
   filename=/learn/test/simplevb.asp

<Test Script Below>


<html><head>
<title>simplevb.asp</title></head>
<body bgcolor="#FFFFFF">
<%
set parrot=server.createobject("charlescarroll.simplecomponent")
parrot.hello
response.write "<br>"
parrot.goodbye
%>
</body></html>

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site