下面是输入文件字符串操作VB.net
DELL NOTEBOOK
1000 USD
ACER NOTEBOOK
HP NOTEBOOK
APPLE MOBILE
900 USD
HTC MOBILE
800 USD
基本上我需要检查是否有第二行的任何单词“USD”,并把 字是或在第一行号。 预期低于输出
DELL NOTEBOOK YES
1000 USD
ACER NOTEBOOK NO
HP NOTEBOOK NO
APPLE MOBILE YES
900 USD
HTC MOBILE YES
800 USD
是我的代码需要一些调整
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
Ahmad-San将保存到另一个文本文件。 – user801207
更新了代码以包含两种方法。你可以注释掉你不想使用的那个 – Ahmad
Ahmad-San,最后一行没有写? – user801207