Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Setting a value of an item in a collection

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 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