There is absolutely no difference what is the language, Urdu or English unless you loose Unicode information. Your input file should use one of Unicode UTFs for encoding.
Avoid using
CStr
. This is a legacy cast operator. You never need it. Instead, use
object.ToString
. You don't need it for this task at all.
Your code is hard to understand, but the search is really simple.
Make sure you read text file correctly. For text files, use
System.IO.StreamReader
, see:
http://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.100%29.aspx[
^].
In most cases, you need to open text files, ASCII and Unicode, using encoding detection based on BOM (see below). ASCII files do not contain BOM, which is also detected correctly. Use this constructor with second parameter set to
true
:
http://msdn.microsoft.com/en-us/library/9y86s1a9.aspx[
^].
If you know that in some files BOM is not present but you know the encoding, you can pass encoding explicitly. In this case, use this:
http://msdn.microsoft.com/en-us/library/x8xxf0x5.aspx[
^].
Read the file line by line using
System.IO.StreamReader.ReadLine
or read the whole file using
ReadToEnd
. Use other read methods when required.
Search for substring in a string using
System.String.IndexOf
methods:
http://msdn.microsoft.com/en-us/library/system.string.aspx[
^].
In general, stop using legacy VB stuff. Use .NET!
Also, you need to understand main ideas of Unicode. Please see:
http://unicode.org/[
^],
http://unicode.org/faq/utf_bom.html[
^].
—SA