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
Solved

How to edit collection variable in VB6 ?

Posted on 2010-11-12
5
844 Views
Last Modified: 2012-05-10
Hi experts!


I’m using collection in VB6.
  Set cAppSet = New Collection

  cAppSet.Add 1, sAPP_HARMONY

But my question is how can I later correct value of this collection ?
I try with
cAppSet(sAPP_HARMONY) = 0

give error, then I try first to delete it and add again, it work, but when I try to access collection I get error.
cAppSet.Remove sAPP_HARMONY
  cAppSet.Add 1, sAPP_HARMONY

and when make
If cAppSet(sAPP_HARMONY) Then

I get error
Object is not longer valid

So – how can I edit collection value ?
0
Comment
Question by:dvplayltd
  • 3
5 Comments
 
LVL 7

Expert Comment

by:rogerard
ID: 34120626
You need to reference as

cAppSet.Item(sAPP_HARMONY) = 0
0
 
LVL 7

Expert Comment

by:rogerard
ID: 34120638
I believe you might also be able to reference it:
cAppSet.Item!sAPP_HARMONY = 0
0
 
LVL 7

Expert Comment

by:rogerard
ID: 34120641
Sorry, this
cAppSet!sAPP_HARMONY = 0
0
 
LVL 22

Accepted Solution

by:
danaseaman earned 500 total points
ID: 34120724
Try using the Scripting Dictionary object which is editable.
Add reference to "Microsoft Scripting Runtime"
Option Explicit

Dim cAppSet          As Scripting.Dictionary
Const sAPP_HARMONY   As String = "AppHarmony"

Private Sub Form_Load()
Set cAppSet = New Scripting.Dictionary

  cAppSet.Add sAPP_HARMONY, 1
  Debug.Print cAppSet(sAPP_HARMONY)
  cAppSet(sAPP_HARMONY) = 3
  Debug.Print cAppSet(sAPP_HARMONY)
  
End Sub

Open in new window

0
 

Author Closing Comment

by:dvplayltd
ID: 34120828
10x. I know Dictinary object from C# and I'm glad it is present in VB6. Thanks !
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 89
VBA filters 2 64
passing a value with stream reader AFTER a ";" 3 74
Advice in Xamarin 21 96
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

808 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