?
Solved

Setting a value of an item in a collection

Posted on 2000-03-18
4
Medium Priority
?
200 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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