borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (press Tab in Tab control?)Next Topic (Find Command?) New Topic New Poll Post Reply
AndreaVB Forum : VB General : get values from a file
Poster Message
humberto
Level: VB Lord

Registered: 13-01-2005
Posts: 246

icon get values from a file

can some one tell me how to read the values of this kind of file

i need to read the File [FName] value

File:

quote:

Version [Real]= 15.0 d E
[cfg]= d E
ScanMode [Short]= 1 d E
[]
[Dir]= d E
[Test_Library]= d E
  Name [String]="Test Library" d E
  File [FName]="C:\test\lib.glf" d E
  []

02-10-2006 at 06:11 AM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: get values from a file

try this code:

Option Explicit

Private Sub Command1_Click()
    Dim f As Integer
    Dim s As String
    Dim strFileName As String
    Dim p1 As Integer
    Dim p2 As Integer
    
    f = FreeFile
    Open "d:\test.txt" For Input As f
    Do While Not EOF(f)
        Line Input #f, s
        p1 = InStr(s, "[FName]")
        If p1 > 0 Then
            'we've found the string in the current line
            'then search for the first (") character after [FName] position
            p1 = InStr(p1, s, """")
            If p1 > 0 Then
                'search the second (") character
                p1 = p1 + 1
                p2 = InStr(p1, s, """")
                If p2 > 0 Then
                    'extract the file name value
                    strFileName = Mid(s, p1, p2 - p1)
                    MsgBox strFileName
                    Exit Do
                End If
            End If
        End If
    Loop
    Close f
End Sub


____________________________
AndreaVB

25-10-2006 at 07:00 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : get values from a file
Previous Topic (press Tab in Tab control?)Next Topic (Find Command?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder