Submitted by: 
Visitors have accessed this post 2832 times.
  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
  7. AssignVariables:
  8. NF = FreeFile
  9. ReadIniValue = ""
  10. KEY = "[" & LCase$(KEY) & "]"
  11. Variable = LCase$(Variable)
  13. EnsureFileExists:
  14. Open INIpath For Binary As NF
  15. Close NF
  16. 'SetAttr INIpath, vbArchive
  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.


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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe>
  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.