Solved

Collection objects in ASP

Posted on 1998-02-25
5
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The viewer will learn how to count occurrences of each item in an array.
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…

622 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