Write.ini

Language
  1. Public Function ReadIniValue(INIpath As String, KEY As String, Variable As String) As String
  2. Dim NF As Integer
  3. Dim temp As String
  4. Dim LcaseTemp As String
  5. Dim ReadyToRead As Boolean
  6.    
  7. AssignVariables:
  8.         NF = FreeFile
  9.         ReadIniValue = ""
  10.         KEY = "[" & LCase$(KEY) & "]"
  11.         Variable = LCase$(Variable)
  12.    
  13. EnsureFileExists:
  14.     Open INIpath For Binary As NF
  15.     Close NF
  16.     'SetAttr INIpath, vbArchive
  17.    
  18. LoadFile:
  19.     Open INIpath For Input As NF
  20.     While Not EOF(NF)
  21.     Line Input #NF, temp
  22.     LcaseTemp = LCase$(temp)
  23.     If InStr(LcaseTemp, "[") <> 0 Then ReadyToRead = False
  24.     If LcaseTemp = KEY Then ReadyToRead = True
  25.     If InStr(LcaseTemp, "[") = 0 And ReadyToRead = True Then
  26.         If InStr(LcaseTemp, Variable & "=") = 1 Then
  27.             ReadIniValue = Mid$(temp, 1 + Len(Variable & "="))
  28.             Close NF: Exit Function
  29.             End If
  30.         End If
  31.     Wend
  32.     Close NF
  33. End Function

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment