Last post Jan 24, 2018 02:35 AM by afastars
Jan 24, 2018 12:27 AM|afastars|LINK
i using ReadLines to search IPV4 address in file, but its not work as expected. need help from expert here. Below is my code.
For Each line As String In File.ReadLines("D:\IP.txt")
If line.CompareTo(IP) Then
Response.Write(" Detect IP")
Response.Write(" NOT Detect IP")
Jan 24, 2018 12:44 AM|mgebhard|LINK
The string.CompareTo() method returns the position of a string within another string.
See the docs. https://msdn.microsoft.com/en-us/library/35f0x18w(v=vs.110).aspx
The only time string.CompareTo() returns 0 (false) is when the line exactly matches the IP variable. Otherwise, the method always returns a non-zero value or true.
You can figure this out on your own by learning how to use the Visual Studio debugger.
Jan 24, 2018 02:35 AM|afastars|LINK
Thanks for replied, basically instead of use If line.CompareTo(IP) i'm using If line.Equals(IP) and its work. However your post gave me some idea to resolve my problem.