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




Reply With Quote