Results 1 to 4 of 4

Thread: check of any value exist in a txt file

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908

    check of any value exist in a txt file

    Is it possible to check if there is any value in a txt.file?
    ie: If Open "C:\xxx.txt"= "" then....

    what will be the correct expression above?

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Open the file for reading, read in each line, check for your string, if it exists do your routine, if it it doesnt read the next line. Do until you reach the end of the file.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    how do i check for the existence forany string?
    i use this:

    Get #intFNum, 1, intClickCount
    If intClickCount ="" Then
    Put #intFNum, 1, 1
    Else
    intClickCount = intC....


    the intClickCount ="" is not correct....how to expression it?

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Option Explicit
    2.  
    3. Private Function GetFileContents(fileName As String) As String
    4.     If Dir(fileName) <> "" Then
    5.         Open fileName For Binary As #1
    6.             GetFileContents = Input(LOF(1), 1)
    7.         Close #1
    8.     End If
    9. End Function
    10.  
    11. Private Sub Command1_Click()
    12.     If InStr(GetFileContents("c:\autoexec.bat"), "data to search for") Then
    13.         'do your struff
    14.     Else
    15.         'doesnt exist... what now
    16.     End If
    17. End Sub
    -= a peet post =-

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