N342 ActiveX |
The following simple example is intended to provide the nuts and bolts
of implementing an ActiveX component in Visual Basic and using the component
in a VBScript (or JavaScript or PerlScript would work the same) on a server.
| Visual Basic - HelloWorldClass
Option Explicit 'Global scripting context
'Automatically called when object is instantiated Public Sub OnStartPage(ASP_Scripting_Context As ScriptingContext) 'Set global variable to reference End Sub Public Sub Greeting(myName As String) Dim ASPResponse ' Create Response object from ASPResponse.Write "<textarea>" ASPResponse.Write "Hello World " + myName ASPResponse.Write "</textarea>" End Sub |
HelloWorld.Asp
<H1>VB HelloWorldClass</H1> <% ' Create our HelloWorldClass object
' Call Greetings subroutine
%>
Output
|
Exercise 1 - Creating the HelloWorldClass in Visual Basic
|