Notes for ASP + COM

Source: Internet
Author: User

As we all know, ASP is a non-typed scripting language, while DLL components developed by VB, Vc, Delphi and other languages are all strongly typed, which leads to a problem. this will cause problems. let me talk about the problem I encountered. I use VB to write a test class and there is a method FUNA. the return value of the method FUNA is an array, for example: Code :
Class test:

Public Function getstr ()
Getstr = Split ("a, B, c, d ",",")
End Function

ASP code:

Dim o
Set o = server. Createobject ("bqrm. test ")
Dim arr
Arr = O. getstr ()
Response. Write (typename (ARR) 'output string ()
Response. Write (isarray (ARR) 'outputs true
Response. Write (ARR (0) 'output type does not match. isarray returns an array, but you cannot treat it as an array.

But the code of the getstr method can be used, for example:
Public Function getstr ()
Getstr = array ("A", "B", "C", "D ")
End Function
In this way, no errors will occur. However, sometimes you cannot list all the elements, so you have to write a function and convert it into a non-type array,

Function getvbsarray (byval ARR)
If isarray (ARR) then
Dim arrtmp ()
Redim arrtmp (ubound (ARR ))
Dim ibound
Ibound = 0
Dim TMP
For each TMP in arr
Arrtmp (ibound) = TMP
Ibound = ibound + 1
Next
Getvbsarray = arrtmp
Erase arrtmp
Else
Getvbsarray = arr
End if
End Function
Put it in a module, and convert it to the following before returning the array method:

Public Function getstr ()
Getstr = getvbsarray (split ("a, B, c, d ",","))
End Function
In this way, there is no problem.

BTW, however, in the past, I thought it was a very difficult problem. In fact, I was blindfolded by my ignorance. I only know a bit about vbs, but I don't know about VC and Delphi. I don't want to talk about that anymore, saving my b4 ....... pai_^

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.