Pass Arrays ByVal From ASP Scripts to VB COM Objects

Pass Arrays ByVal From ASP Scripts to VB COM Objects

In Microsoft Knowledge Base article Q217114, “How to: Implement Array Arguments in Visual Basic COM Objects for Active Server Pages,” Microsoft says you can’t pass an array to a COM method by value. However, you want to do this for Microsoft Transaction Server (MTS), so here is a workaround that does it ByVal. Add a file called test.asp with this Active Server Page (ASP) code to a virtual Internet Information Server (IIS) directory:

 <%dim PassArrayByValWorksdim ary(1)dim iReturnary(0) = "firstone"ary(1) = "2ndone"' pass the array to a non array declared variable then ' pass the non array variable insteadPassArrayByValWorks = arydim objset obj = server.createobject ("prjFormCheck.clsFormCheck")iReturn = obj.formcheck(PassArrayByValWorks, 0)%><%=iReturn%>' build ActiveX dll named "prjFormCheck", name ' class "clsFormCheck" add the function below ' and start it in the VB IDEPublic Function FormCheck(ByVal _	arrFldNameValuePairs As Variant, ByVal _	ErrLogType As Variant) As Variant	If IsArray(arrFldNameValuePairs) Then		FormCheck = "You can do it!"		Debug.Print arrFldNameValuePairs(0)		Debug.Print arrFldNameValuePairs(1)	Else		FormCheck = "Didn't work"	End IfEnd function

Right-click on the test.asp file in the virtual directory of IIS and click on Browse. The browser should show “You can do it!”

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several