admin Level: Administrator

 Registered: 04-04-2002 Posts: 530
|
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
|