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 7440133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:48:20+00:00 2026-05-29T10:48:20+00:00

I want to use a Dictionary as a private variable in a module. I

  • 0

I want to use a Dictionary as a private variable in a module. I tried the following code, but the vba editor marks the collection (variable resource) red when I want to access it in a procedure. How do I have to code this?

Option Explicit

Private Type Translation
    german As String
    french As String
    italian As String
End Type

Private resource
Set resource = CreateObject("scripting.dictionary")

Public Sub addTranslation(key As String, g As String, f As String, i As String)
    Dim trx As Translation
    trx.german = g
    trx.french = f
    trx.italian = i

    resource.add(key, trx)  '<== marked red
End Sub

'more methods to come which do access resource
  • 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-29T10:48:20+00:00Added an answer on May 29, 2026 at 10:48 am

    The instancing:

    Set resource = CreateObject("scripting.dictionary")
    

    Needs to be in a sub/function not in the declaration, you can add it somewhere convenient or change the declaration to:

    Private resource as object
    

    and add a guard check whenever you access it (instancing it once elsewhere is obviously better);

    If resource Is Nothing Then Set resource = CreateObject("scripting.dictionary") 
    

    And no parens in the .add call so:

    resource.Add key, trx
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in
I have the following code: private Dictionary<int, Entity> m_allEntities; private Dictionary<Entity, List<IComponent>> m_entityComponents; public
In my class, I want to use a dictionary with the following declaration: Dictionary<string,
I'm want to use either a hash table or a dictionary in my access
I want to use my dictionary keys for output in a grouped table. This
I have the following Dictionary: private Dictionary<string, double> averages = new Dictionary<string, double>(); Now
I want to use a Dictionary(Of Key, Value), and the Key is not a
I have an IDictionary, now I want to use these values in a selectlist.
I want use groovy findAll with my param to filtering closure filterClosure = {
i want use some data from a website with web service. i have a

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.