Read and write the four functions of the INI file 'file name SOURCEDB.INI file
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 WritePrivateProfileString LIB "kernel32" alias
"WritePrivateProfileStringa" (Byval LPApplicationName Assy, Byval LpkeyName As Any, ByVAL
LPSTRING As Any, Byval LPFileName As String) AS Long
'The following two functions, read / write INI files, fixed nods setting, in_key is the primary key written / read
'Is only non-valued
'Y: Yes, N: NO, E: Error
Public Function Getinitf (byvalin_key as string) as boolean
ON Error Goto GetinitFERR
Getinitf = TRUE
Dim getstr as string
Getstr = vba.string (128, 0)
GetPrivateProfileString "Setting", in_key, "", getstr, 256, app.path & "/sourcedb.ini"
Getstr = vba.replace (getstr, vba.chr (0), "")
IF getstr = "1" THEN
Getinitf = TRUE
Getstr = ""
Else
Goto GetinitFerr
END IF
EXIT FUNCTION
GetinitFERR:
Err.clear
Getinitf = false
Getstr = ""
END FUNCTION
Public Function Writeinitf (Byval in_Key As String, Byval in_Data as boolean) AS Boolean
ON Error Goto WriteinitFERR
Writeinitf = TRUE
IF in_data = True Then
WriteprivateProfileString "Setting", IN_KEY, "1", app.path & "/sourcedb.ini"
Else
WriteprivateProfileString "Setting", IN_KEY, "0", app.path & "/sourcedb.ini"
END IF
EXIT FUNCTION
WriteinitFERR:
Err.clear
Writeinitf = false
END FUNCTION
'The following two functions, read / write INI files, unfixed nodes, IN_KEY is the primary key to write / read
'Direction of string values
'Null value indicates an error
Public Function GetInistr (Byval Appname As String, Byval In_Key As String) AS STRING
ON Error Goto Getinistrerr
IF VBA.TRIM (in_key) = "" ""
Goto Getinistrerrrrrrrrr
END IF
Dim getstr as string
Getstr = vba.string (128, 0)
GetPrivateProfileString Appname, In_Key, "", Getstr, 256, App.Path & "Sourcedb.ini"
Getstr = vba.replace (getstr, vba.chr (0), "")
IF getstr = "" "
Goto Getinistrerrrrrrrrr
Else
Getinistr = GetStr
Getstr = ""
END IF
EXIT FUNCTION
Getinistrer:
Err.clear
Getinistr = ""
Getstr = ""
END FUNCTION
Public Function Writeinistr (Byval IN_KEY As String, Byval in_Data as string) as boolean
ON Error Goto WriteiniSTrerr
Writeiniistr = TRUE
IF VBA.TRIM (in_data) = "" or vba.trim (in_key) = "" "or vba.trim (appname) =" "" "" "
Goto Writeinistrerr
Else
WriteprivateProfileString Appname, In_Key, In_Data, App.Path & "/sourcedb.ini"
END IF
EXIT FUNCTION
Writeinistrerr:
Err.clear
Writeinistr = false
END FUNCTION