ASP component primary entry and master series

zhaozj2021-02-16  108

I have always wanted to write some components, which can finally write something you like.

I hope that after learning these tutorials, you can write your own components as you wish.

Each article may not be associated, just writing some of the problems that occur during the process of writing.

Welcome everyone to criticize

Environment: WinXP VB6 SP6 Visual InterDev6.0

As the first one, let's write a relatively simple component

The completed function is: Enter two numbers, return additional results

Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM, the class name is modified to FC1

Click on the menu -> Tool -> Add Procedure

We enter the add, type selection function in the name, and the scope select the public, then determine

Buy the following code, we continue to improve

Option expedition

Public Function Add (Byval A As Long, BYVAL B AS Long) As long

Add = a b

END FUNCTION

OK, a simple component is written, click on the menu -> File -> Generate the FCOM.dll file

Determine, there will be an FCOM.dll file in the directory.

test

Open Visual InterDev6.0, generate an ASP file, why use InterDev, because it has code prompt function, consistent with the VB IDE environment, easy to write

<% @ Language = VBScript%>

<%

Set obj = server.createObject ("fcom.fc1")

'The following note, because the function has a return value, can not be written according to the method below, otherwise IE will report an error

'Obj.add (3, 4)

'Error Type:' Microsoft VBScript Compiler Error (0x800A0414) 'When calling a subroutine, parentheses cannot be used in brackets' /xml/fc1.asp, line 9, column 12'obj.Add (3, 4)

'The following is correct way to write

DIM C

c = obj.add (3, 4)

Response.write C

%>

Configure a virtual directory, perform this ASP file in IE, resulting in results 7

The first one is over, I wish you all a happy study.

转载请注明原文地址:https://www.9cbs.com/read-10507.html

New Post(0)