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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:16:17+00:00 2026-05-15T23:16:17+00:00

the title may not be appropriate because I don’t really know how I should

  • 0

the title may not be appropriate because I don’t really know how I should put this.
I have a template where I have a “Module1” module and a “ThisDocument” code.
Module1 contains the following code to pick up values from the registry.
I pick up these values from ThisDocument code.

What I want is to move the code from ThisDocument over to it’s own module. And being able to access the values from all other modules or subs.

Right now, ThisDocument has code that looks a little like this:

regPath = ReadIni(File, "Registry", "Path")
regString = ReadIni(File, "Registry", "String")
regStrFirstname = ReadIni(File, "Fields", "Firstname")
regStrLastname = ReadIni(File, "Fields", "Lastname")
regStrInitials = ReadIni(File, "Fields", "Initials")
regStrFullname = ReadIni(File, "Fields", "Fullname")

So, instead of having this code in ThisDocument, I would like to have this code in a separate Module and being able to access the values from ThisDocument directly. This way I can pick up the values from, say a form as well. Populate textboxes with the values etc.

How should I do this?

Module1 looks like this:

Private Declare Function GetPrivateProfileSection Lib "kernel32" Alias _
"GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileSection Lib "kernel32" Alias _
"WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
ByVal lpString As Any, ByVal lpFileName As String) As Long

'// INI CONTROLLING PROCEDURES
'reads an Ini string
Public Function ReadIni(Filename As String, Section As String, Key As String) As String
Dim RetVal As String * 255, v As Long
v = GetPrivateProfileString(Section, Key, "", RetVal, 255, Filename)
ReadIni = Left(RetVal, v + 0)
End Function

'reads an Ini section
Public Function ReadIniSection(Filename As String, Section As String) As String
Dim RetVal As String * 255, v As Long
v = GetPrivateProfileSection(Section, RetVal, 255, Filename)
ReadIniSection = Left(RetVal, v + 0)
End Function
  • 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-15T23:16:18+00:00Added an answer on May 15, 2026 at 11:16 pm

    Make the variables functions. You basically want global variables accessible everywhere. The way to do that is to capsulate the variables.

    In Module1 (or a new module) add:

    Function regPath()
            regPath = ReadIni(File, "Registry", "Path")
    End Function
    

    Hope it helps.

    If you want to get even more sophisticated you can work with objects.

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

Sidebar

Related Questions

Okay the question title may not have made sense... mostly because I don't know
The title may be not exactly, but I don't know how to express it.
The title may not really explain what I'm really trying to get at, couldn't
this title may not best describe my problem. I'm using Netbean GUI builder to
May be my title is not clear. I am looking for some kind of
my title may not be clear. But basically what I want to do is:
(The title may not be proper but I try my best to phrase it)
Ok, this may not be related to EF. I am trying to use the
I have a collection of mp3, wma's etc that may or may not have
Title is the entire question. Can someone give me a reason why this happens?

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.