dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Apr 27, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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 PassArrayByValWorks
dim ary(1)
dim iReturn
ary(0) = "firstone"
ary(1) = "2ndone"
' pass the array to a non array declared variable then 
' pass the non array variable instead
PassArrayByValWorks = ary
dim obj
set 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 IDE
Public 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 If
End 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!"
Mark Kanter
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date