Solved

Setting a value of an item in a collection

Posted on 2000-03-18
4
199 Views
Last Modified: 2010-05-02
Public DLS(1 to 2) as new collection 'in module

... later on in mdi form

msgbox DLS(2).item(x) ' this works fine
DLS(2).item(x)="6" ' Error Object Reqiured... what is the matter with this?
0
Comment
Question by:hess
[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
  • 2
4 Comments
 
LVL 28

Expert Comment

by:Ark
ID: 2632486
Hi
Set DLS(2).item(x)="6"
Cheers
0
 
LVL 28

Expert Comment

by:Ark
ID: 2632491
Hi
Sorry, ignore my previous message
Correct code:
DLS(2).Remove x
DLS(2).Add "6", , x
Cheers
0
 

Accepted Solution

by:
FWAllan earned 50 total points
ID: 2632740

You can add to and remove items from a collection.  You cannot alter the immediate value of a member of the colection.  Generally these would be objects and classes.

You can, however, update the properties of any object that you have put into a collection.

EG

Form has a textbox called txt_Any
and a command button cmd_update


Then in a module

sub cmd_update_click()
' This will update the textbox on the
' screen with a new value

  dim col as collection

  col.add txt_any, "txt_Any"

  col.item("txt_Any").text = "The value"
end sub


What you could do is create a class
called c_Text with the following lone line of code:

Public Text as string


And then in a module or form


sub etc()

  dim avalue as new C_text
 
  C_text.text = "First value"

  col.add avalue , "key1"

  col.item("key1").text = "value2"

end sub
0
 

Author Comment

by:hess
ID: 2634941
That is what I thought the case was. Thankyou for asuring me.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

724 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