Solved

Collection objects in ASP

Posted on 1998-02-25
5
169 Views
Last Modified: 2013-12-25
I have written an ActiveX DLL that has a method which returns a Collection object to an ASP page.
In the ASP page I cannot change the value of any of the items in the collection.
col.item("example") = "example"
does not work.
The methods add and remove on the other hand do work on the collection object. Does anyone have a sollution to this problem ?
0
Comment
Question by:ddiego
  • 3
5 Comments
 
LVL 3

Accepted Solution

by:
hkp earned 100 total points
ID: 1857584
Could you be more specific, by showing the code?

Create the object - like the following - in the ASP file:
<%
   Set col = Server.CreateObject("MyDLL.MyClassName")
   col.MyMethod("example") = "examples value"
   strExample = col.Item("example")
   = strExample  ' shows "examples value"
%>

The MyDll is the name of the DLL file. Make sure the DLL is accessible from within ASP.
The MyClassName is the name of the component class you created.
Remember to make the component Public.
The MyMethod is the method returning the collection object instance item of the component class.

I hope this helps.
0
 

Expert Comment

by:diegod
ID: 1857585
Unfortunatly this doesn't answer my question because it doesn't say anything about changing the value of an item in a collection. Your code is about what I have, so the problem isn't related to instantiation problems, etc.
0
 
LVL 3

Expert Comment

by:hkp
ID: 1857586
Could you tell us what product you have used to make your ActiveX DLL. I have a feeling that the DLL isn't made, correctly.
(I assume you use Visual Basic 5.0).

You cannot make assignments using the Item method of a Collection object. This method is a Read only method.

Instead, try to make a public subroutine to make the change (see later) which takes a key as the argument, and the new value.

The value change can be emulated by removing the old item for the given existing key , then adding the item again, using the new value, like:

Public Sub Change(oCol, strKey, NewValue)
   oCol.Remove strKey
   oCol.Add item:=NewValue, key:=strKey
End Sub

You can then from the ASP obtain your goal by the following line:

<% col.Change("example","123")
= col.item("example") ' this should display: 123
%>

In your search for the answer: "Good luck"

0
 

Author Comment

by:ddiego
ID: 1857587
This will most certainly do the trick. I have however one more related question that someone might be able to answer:
Is an Asp dictionary object the same as a VB collection object ?
0
 
LVL 3

Expert Comment

by:hkp
ID: 1857588
They are very similar, but the VB Collection holds less properties than a VBScript Dictionary object. So, a Dictionary object in VBScript (in ASP) is not the same as a Collection object of VB. The VB object has only: Remove, Add, Item, and Count methods/properties.



0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now