VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



These two functions are usefull for reading .ini files. GetBefore returns everything in the string

by DiskJunky (16 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 4th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

These two functions are usefull for reading .ini files. GetBefore returns everything in the string before the "=" sign. GetAfter, returns all

Rate These two functions are usefull for reading .ini files. GetBefore returns everything in the string



'string before the "=" sign.

Const Sign = "="

Dim Counter As Integer
Dim Before As String

'find the position of the equals sign
Counter = 1
For Counter = 1 To Len(Sentence)
    If Mid(Sentence, Counter, 1) = Sign Then
        'break loop on first equals sign.
        Exit For
    End If
Next Counter

If Counter <> Len(Sentence) Then
    Before = Left(Sentence, (Counter - 1))
Else
    Before = ""
End If

GetBefore = Before
End Function


Public Function GetAfter(Sentence As String) As String

'string after the "=" sign.

Const Sign = "="

Dim Counter As Integer
Dim Rest As String

'find the position of the equals sign
Counter = 1
For Counter = 1 To Len(Sentence)
    If Mid(Sentence, Counter, 1) = Sign Then
        'break loop on first equals sign.
        Exit For
    End If
Next Counter

If Counter <> Len(Sentence) Then
    Rest = Right(Sentence, (Len(Sentence) - Counter))
Else
    Rest = ""
End If

GetAfter = Rest
End Function


Download this snippet    Add to My Saved Code

These two functions are usefull for reading .ini files. GetBefore returns everything in the string Comments

No comments have been posted about These two functions are usefull for reading .ini files. GetBefore returns everything in the string . Why not be the first to post a comment about These two functions are usefull for reading .ini files. GetBefore returns everything in the string .

Post your comment

Subject:
Message:
0/1000 characters