-
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
-
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.
-
InStr(strSearchFor)
hmmm..
Could somebody expand on this?