VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Reads strings from an INI file.

by Michael A. Cojocari (1 Submission)
Category: Games
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 14th April 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Reads strings from an INI file.

Rate Reads strings from an INI file.



' Written by Michael A. Cojocari
' All rights reserved.
'
'
' Anyone is free to use these functions in any particular way.
' Any sugestions?  Email [email protected]


'Reads strings from INI files

Function readstringINI(ini_file As String, ini_section As String, ini_entry As String, default As String) As String

 Dim section As String, entry As String

 Dim foundsection As Integer

 Dim foundentry As Integer

 Open ini_file For Input As #1



 'Finding the section...

 Do While (Not EOF(1)) And (foundsection = 0)

  Line Input #1, section

  If Left(section, 1) = "[" Then

   foundsection = InStr(section, ini_section)

  End If

 Loop

 

 'Finding the entry...

 If foundsection = 0 Then

  'MsgBox "Section not found"

 Else

  Do

   Line Input #1, entry

   foundentry = InStr(entry, ini_entry)

  Loop While (Not EOF(1)) And (foundsection <> 0) And (foundentry = 0) And (Left(entry, 1) <> "[")

  'If foundentry = 0 Then MsgBox "Entry not found"

 End If

 

 If (foundsection <> 0) And (foundentry <> 0) Then

  Dim position As Integer, length As Integer

  position = InStr(entry, "=")

  length = Len(entry)

  position = length - position

  readstringINI = Right(entry, position)

 Else

  readstringINI = default

 End If

 

 Close #1

End Function





Download this snippet    Add to My Saved Code

Reads strings from an INI file. Comments

No comments have been posted about Reads strings from an INI file.. Why not be the first to post a comment about Reads strings from an INI file..

Post your comment

Subject:
Message:
0/1000 characters