Below is the input file
DELL NOTEBOOK
1000 USD
ACER NOTEBOOK
HP NOTEBOOK
APPLE MOBILE
900 USD
HTC MOBILE
800 USD
Basically I need to check if there any word “USD” on the second line and put
the word Yes or No. on the first line.
Expected Output
DELL NOTEBOOK YES
1000 USD
ACER NOTEBOOK NO
HP NOTEBOOK NO
APPLE MOBILE YES
900 USD
HTC MOBILE YES
800 USD
below is my code that need some tweak
Sub Main()
Dim fh As StreamReader
fh = new StreamReader("list.txt")
dim currency as string
dim bCurrency as boolean
Dim s As String = fh.ReadLine()
While not s Is Nothing
currency = s.substring(5,3)
if currency = "USD" then
bCurrency = True
else
if bCurrency = true then
Console.WriteLine(s & " Yes")
bCurrency = False
else
Console.WriteLine(s & " No")
end if
end if
s = fh.ReadLine
End While
fh.Close()
End Sub
Edited to include Saving to file and on screen both.
Do you want the final output to be printed to the screen, or saved into another text file?
Here is the way it would appear on screen
AS WELL AS SAVED to OUTPUT.TXT