Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:26:03+00:00 2026-05-14T15:26:03+00:00

I know this is a simple question but it’s aggravating me. If I have

  • 0

I know this is a simple question but it’s aggravating me. If I have a key/value pair in a collection but I can’t seem to get the value out using the key. I can get the key using the value but not vice versa. Is there some magical way to accomplish this?

For example:

Dim CycleList As Collection
Dim Value as String
Set CycleList = New Collection
CycleList.Add 1, "Some Value"


Value = CycleList(1)

I’ve also tried CycleList.Item(1) and it’s the same result, Value = 1.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:26:04+00:00Added an answer on May 14, 2026 at 3:26 pm

    The reason is that you are telling VBA to add an integer 1 with an alternate key of Some Value to the collection. When you call CycleList(1), you are asking for the Item with an index of 1 which happens to be the value 1. The second parameter Some Value represents an alternate key you can use to find the item you want. Here’s an example to illustrate:

    Public Sub Foo()
        Dim bar As Collection
        Set bar = New Collection
        bar.Add 1, "Blah"
        bar.Add "Foobar"
        bar.Add 99
    
        Debug.Print "bar(""Blah""): " & bar("Blah")
        Debug.Print "bar(1): " & bar(1)
        Debug.Print "bar(2): " & bar(2)
        Debug.Print "bar(3): " & bar(3)
    End Sub
    

    Results when calling Foo in the debug window:

    bar("Blah"): 1
    bar(1): 1
    bar(2): Foobar
    bar(3): 99
    

    Note that in the first Debug.Print, I ask for the value by key but in the others, I’m asking for the value by index.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question was asked before but I have the following simple code
I know that this is a simple question for PHP guys but I don't
I know this is a darn simple question, but I'm very used to using
I know this isn't strictly a programming question but y'all must have experienced this.
I know this is a very simple question, but unfortunately I don't know enough
( I know this is probably a simple question to answer, but I don't
This is a simple question, but I have not ran across similar code before
I just have one simple question about XSS attack. I know that you can
I know this question has been asked/answered but I can't find it for the
Warning - I am very new to NHibernate. I know this question seems simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.