View Single Post
  #15 (permalink)  
Old January 7th, 2005, 08:46 AM
SerranoG SerranoG is offline
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Here, this may help.

Code:
Private Sub Command2_Click()

    Dim TextLine$, Filename$
    Dim FileHandle As Integer
    Dim strUserName As String

    Filename$ = "Test.BAT"

    ' Test if the file exists
    If Dir(Filename$) = "" Then Exit Sub

    FileHandle = FreeFile ' This is safer than assigning a number
    Open Filename$ For Input As #FileHandle

    ' Initialize the user in case it's not found in the BAT file
    strUserName = "Not Found"

    Do While Not EOF(FileHandle)      ' Loop until end of file
        Line Input #FileHandle, TextLine$  ' Read line into variable
        If Instr(Textline$,"=") > 0 Then 
            strUserName = Mid(TextLine$, InStr(TextLine$, "=") + 2)
        End If
    Loop

    Close #FileHandle
    Me.Label1.Caption = strUserName

End Sub

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote