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:

 ' 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: