pass collection from vb to asp

W

Wandy Tang

Dear All,

How to pass a collection from a VB Component to an ASP page? I have no clue
the syntax of all.
Many Thanks.

Regards,
Wandy Tang
 
R

Ray at

It seems that the collection would be a member of your object.

For Each Thing In yourObject.CollectionClass
Response.Write Thing.Someproperty
Next
 
W

W.Tang

Dear All,

Can show the exact source, sorry I am kind of stupid here
Many Thanks

Regards
Wandy Tang
 
R

Ray at

Not without knowing the object model of your component!

Here's an example with a commonly known component.


<%
Dim oFSO, oFolder, oCollectionOfSubfolders, ItemInThisCollection
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFOlder = oFSO.GetFolder("C:\inetpub\wwwroot")
Set oCollectionOfSubfolders = oFolder.Subfolders
For Each ItemInThisCollection in oCollectionOfSubfolders
Response.Write ItemInThisCollection.name & "<br>"
Next
Set oFolder = Nothing
Set oFSO = Nothing
%>


Ray at work
 
C

Chris Barber

A collection is an object in its own right and as such can be passed back to
ASP as the return form a function.

In the ASP there is no method of declaring a variable to be a collection
unless you use a collection class to wrap the collection object in something
that can be instantiated so generally speaking you won't have any
intellisense for the collection object so you have to call the methods and
properties 'blind'.

eg. VB:
[In myobject class of mydll COM component]

Function GetCollection() as Collection
Set GetCollection = New Collection
End Function

In ASP:
Dim pobjObject
Dim pcolCollection

Set pobjObject = Server.CreateObject("mydll.myobject")
Set pcolCollection = pobjObject.GetCollection()
With pcolCollection
Response.Write "There are " & pcolCollection.Count & " objects in the
collection."
End With

Set pcolCollection = Nothing
Set pobjObject = Nothing

Collection Classes
http://msdn.microsoft.com/library/d.../html/vaconCreatingYourOwnCollectionClass.asp

Chris.

Dear All,

How to pass a collection from a VB Component to an ASP page? I have no clue
the syntax of all.
Many Thanks.

Regards,
Wandy Tang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top