Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Collection objects in ASP

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
ddiego
Asked:
ddiego
  • 3
1 Solution
 
hkpCommented:
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
 
diegodCommented:
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
 
hkpCommented:
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
 
ddiegoAuthor Commented:
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
 
hkpCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now