Results 1 to 2 of 2

Thread: [Resolved] Reading From File

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Location
    Merced
    Posts
    868

    Resolved [Resolved] Reading From File

    Is It Possible To Read Test From File And If The Word Message Exist In The File Then Show A MessageBox?
    Last edited by GDOG34; May 11th, 2007 at 04:39 PM.

  2. #2
    Addicted Member
    Join Date
    Jun 2006
    Posts
    172

    Re: Reading From File

    vb Code:
    1. Dim Fn As Integer
    2. Dim s As String
    3.  
    4. Fn = FreeFile
    5.  
    6. Open "filename.txt" For Input As #Fn
    7. Do While Not EOF(Fn)
    8.     Input #Fn, s
    9.  
    10.     If s = "Message" Then
    11.          MsgBox "Found Message!"
    12.     End If
    13.    
    14. Loop
    15. Close #Fn

    Though, that assumes "Message" is alone on it's own line. You might want to use..

    vb Code:
    1. If InStr(1, s, "Message", vbTextCompare) Then
    2.       MsgBox "Found Message in: " & s
    3. End If
    • If you found my post to be helpful, please rate me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width