devxlogo

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!”

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist