Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Collection objects in ASP

Posted on 1998-02-25
5
Medium Priority
?
181 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 400 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

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 …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

688 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