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

  • SEARCH
  • Home
  • 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 6153743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:08:36+00:00 2026-05-23T20:08:36+00:00

I’m simply trying to construct a dictionary of productIDs dim viewableProductIDs : set viewableProductIDs

  • 0

I’m simply trying to construct a dictionary of productIDs

dim viewableProductIDs : set viewableProductIDs = CreateObject("Scripting.Dictionary")
    do while not rsEntry.EOF
        viewableProductIDs.Add rsEntry("ProductID"), true
        rsEntry.MoveNext
    loop

rsEntry is a ADODB Recordset and I have made sure, through exhaustive debbug printing, that my query is indeed returning unique productIDs and that the recordset has no duplicates. Yet someohow, vbscript insists on thinking there are duplicates. It’ll add the first one fine, but after that it errors out on all the rest. I tried surrounding it with a check for existing key and it someohow thought they all, but the first, existed. Then in the end I’m left with a dictionary with only one entry in it.

Does anyone have any idea as to why it’s doing this?

  • 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-23T20:08:38+00:00Added an answer on May 23, 2026 at 8:08 pm

    Try adding .Value:

    viewableProductIDs.Add rsEntry("ProductID").Value, true
    

    Explanation:

    VBScript has a concept called “default” properties. For instance, the line

    someString = rsEntry("ProductID")
    

    really is shorthand for

    someString = rsEntry.Fields.Item("ProductID").Value
    

    where Fields, Item, and Value are all the default properties of their respective objects. The main problem here is in the last step of the chain: the difference between rsEntry("ProductID") and rsEntry("ProductID").Value. In the above example, since I didn’t use the Set keyword, an object reference would be illegal for the right-hand side of the assignment. Since rsEntry("ProductID") evaluates to a Field object reference, the interpreter takes the next step and expands the default property of the Field object, Value. If I had done

    Set someObj = rsEntry("ProductID")
    

    the interpreter would have set someObj to the Field object reference.

    Now here’s the fun part: the Dictionary object can use any type of value as its keys. It’s more common to use simple values like strings or numbers, but it’s perfectly legal to use arrays or object references. Since an object reference is legal for the first argument of the Dictionary.Add method, the interpreter doesn’t bother to expand the default property and simply uses the Field object reference as the key. Since the Field object reference doesn’t change from record to record, you end up trying to add the same key over and over. Adding .Value makes it explicitly clear to the interpreter that you want the value, not the object.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT

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.