Read INI file...

How can I pass the path of a DB and some parameters from INI file???
guichoAsked:
Who is Participating?
 
paulstampConnect With a Mentor Commented:
Using the procedures above... put them into a module, not a form. That ought to sort it out.
0
 
hesCommented:
Here is an example on how to read/write to ini files

http://www.vb-world.net/tips/tip17.html
0
 
PlinioCommented:
The INIGet and INIPut routines allow you to read and write to INI files. Simply cut and paste the following
                code.

                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

                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

                Public Function INIGet(Keyfilename, Keyarea, Keyname, Keydefault) As String
                Dim a As String
                Dim b As String
                Dim C As String
                Dim D As String
                Dim E As String
                Dim ReturnValue As Long
                a = Keyarea
                b = Keyname
                C = Keydefault
                D = Space$(144)
                E = Keyfilename
                ReturnValue = GetPrivateProfileString(ByVal a, ByVal b, ByVal C, ByVal D, Len(D), ByVal E)
                INIGet = Left$(D, ReturnValue)
                End Function

                Public Sub INIPut(Keyfilename, Keyarea, Keyname, ByVal Keyvalue As String)
                Dim a As String
                Dim b As String
                Dim C As String
                Dim D As String
                Dim ReturnValue As Long
                a = Keyarea
                b = Keyname
                C = Keyvalue
                D = Keyfilename
                ReturnValue = WritePrivateProfileString(ByVal a, ByVal b, ByVal C, ByVal D)
                End Sub
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
guichoAuthor Commented:
When I try to run the application appear this error message:

Compile error:

Constants, fixed-length, arrays, and Declare statements not allowed as Public members of object modules.
0
 
guichoAuthor Commented:
Adjusted points to 60
0
 
guichoAuthor Commented:
Thanks for the tip...
0
All Courses

From novice to tech pro — start learning today.