Solved

Collection objects in ASP

Posted on 1998-02-25
5
175 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

815 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

12 Experts available now in Live!

Get 1:1 Help Now