ASP Component beginner and proficient Series 4

Source: Internet
Author: User

Array Problems

Arrays are used in many programs and are prone to problems.

Let's take a look at the small example

 

Open VB6 and create an ActiveX dll project. Change project name to fcom and class name to FC4

Choose> Tools> Add process.

Enter acceptarray1 in the name, type selection subroutine, range selection public, and then confirm

Operation again: Enter acceptarray2 in the name, select a function as the type, select public as the range, and click OK.

'Function: Pass the array address to the component, use the byref keyword, and assign a value to return

Public sub acceptarray1 (byref varray as variant) as Variant

Varray (0) = "tornado"

Varray (1) = "20"

End sub

 

'Function: returns a string array.

Public Function acceptarray2 () as Variant

Dim A (2) as Variant

A (0) = "tornado"

A (1) = "20"

Acceptarray2 =

End Function

 

OK, a component is ready. Click the menu> File> Generate the fcom. dll file.

OK. The fcom. dll file will appear in the directory.

 

Test

Open visual interdev6.0 and generate an ASP file

 

<% @ Language = VBScript %>

<HTML>

<Body>

<%

Dim OBJ

Set OBJ = server. Createobject ("fcom. FC4 ")

Dim A (2)

'Test the first component method

OBJ. acceptarray1 ()

Response. Write a (0)

Response. Write "<br>"

Response. Write A (1)

Response. Write "<br>"

'Test the second component method

Dim B

B = obj. acceptarray2 ()

For I = 0 to ubound (B)

Response. Write B (I)

Response. Write "<br>"

Next

%>

 

</Body>

</Html>

 

Configure the virtual directory and execute the ASP file in IE. The result is as follows:

Tornado
20
Tornado
20

 

Summary:

String, which is returned by passing the value or as the return value.

If the parameter is passed by reference, set the parameter type to variant. This can avoid some errors. However, try to reduce the number of reference parameters

 

To be continued

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.