Results 1 to 3 of 3

Thread: Sequential files

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    13

    Sequential files

    I need to give a user the choice of searching a txt file for a country begining with the letter they type into an input box, or allowing them to search all countries if the inputbox is blank.
    Below is the code to open the file and read teh contents. This code works but I need to add the Like operator to meet whats required.
    Code:
     Dim objStreamReader As System.IO.StreamReader
            Dim strCountry As String
    
            Dim strSearchFor As String
            strSearchFor = InputBox("Search beginning with a letter, or leave blank to search for all", "Search For Country")
    
            Dim blnSearch As Boolean                               'do I need a bool here?
            blnSearch = (strCountry Like strSearchFor)
    
            With dlgOpenFileDialog
                .filter = "text(*.txt) |*.txt"
                .FileName = "Countries.txt"
                .InitialDirectory = Application.StartupPath & ("..\")
                .ShowDialog()
            End With

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    I don't see what you need a boolean for. Can you even set a boolean with "Like"?
    Use Instr() with strSearchFor to retrieve the files beginning with the selected letter.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    13
    InStr(strSearchFor)

    hmmm..

    Could somebody expand on this?

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