逐行比较字符串
这里的任何人都可以帮助我处理这个
输入文件
Type Reference
WIN 00001
WIN 00001
WIN 00001
MAC 00001
MAC 00001
基本上我需要比较不等于
首选输出的前 3 个字符是否是
类型参考代码
WIN 00001
WIN 00001
WIN 00001
下面的
Dim fh As StreamReader
Dim os as string
fh = new StreamReader("haggis.txt")
Dim s As String = fh.ReadLine()
While not s Is Nothing
os = s.Substring(0,3)
if os <> os then
Console.WriteLine("Write here")
else
end if
s = fh.ReadLine
End While
fh.Close()
End Sub
Anybody here can help me with this
Input file
Type Reference
WIN 00001
WIN 00001
WIN 00001
MAC 00001
MAC 00001
Basically I need to compare if the first 3 character that are not equal
preferred output will be
Type Reference
WIN 00001
WIN 00001
WIN 00001
Code below
Dim fh As StreamReader
Dim os as string
fh = new StreamReader("haggis.txt")
Dim s As String = fh.ReadLine()
While not s Is Nothing
os = s.Substring(0,3)
if os <> os then
Console.WriteLine("Write here")
else
end if
s = fh.ReadLine
End While
fh.Close()
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
声明一个 previousOS 变量,并将其与该变量进行比较。
例如
Declare a previousOS variable, and compare it with that.
e.g.
@Yet Another Geek,你已经很接近了,如果你不想只是关闭程序,你可以关闭流,然后在 else 语句中放置 Exit Sub 调用。这将带您返回到所谓的子程序并继续处理。
@Yet Another Geek, you're close, If you don't want to just close the program you could close the stream and then put an Exit Sub call in the else statement. This would take you back to whatever called the sub and continue processing.