Solved

Setting a value of an item in a collection

Posted on 2000-03-18
4
191 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
  • 2
4 Comments
 
LVL 27

Expert Comment

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

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

18 Experts available now in Live!

Get 1:1 Help Now