VB.net 如何才能实现VB6的Line Input的效果

sxyweiren 2013-12-31 10:36:02
VB6里面有个叫Line Input的函数,不知道大家用没用到过。
此函数的说明是
引用
Line Input # 语句从文件中一次读取一个字符,直到它遇到回车 (Chr(13)) 或回车-换行 (Chr(13) + Chr(10)) 序列为止。回车–换行序列将被跳过,而不是附加到字符串后面。


我现在有一个文件,普通换行是用Chr(10)完成的,分段是用回车-换行 (Chr(13) + Chr(10))完成的。

在VB6里就能实现一段一段的读入数据,但是在VB.net里面的LineInput函数只能一行一行的读入。

有没有一个简单的方案实现这种效果?最好有现成的函数调用之类的。

实在不行就只能写代码了。
...全文
331 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyyyyhhhhwwww 2014-01-13
  • 打赏
  • 举报
回复
split是不错的选择,分割成数组也可以。
sxyweiren 2014-01-06
  • 打赏
  • 举报
回复
额,总之得重新写一个。 为什么微软提供的LineInput方法不好用呢?VS自动把Line Input给升级成LineInput了,但是却不好用。郁闷
sxyweiren 2014-01-06
  • 打赏
  • 举报
回复
引用 5 楼 vbfool 的回复:
毕竟是兼容性的函数,还是用StreamReader的ReadLine比较好一些。
StreamReader只能实现读取一行吧?读取一段好像不好实现啊。好像只能通过ReadToEnd然后Split实现。
vbfool 2014-01-06
  • 打赏
  • 举报
回复
毕竟是兼容性的函数,还是用StreamReader的ReadLine比较好一些。
本拉灯 2014-01-01
  • 打赏
  • 举报
回复
写一个吧。
难得胡图 2014-01-01
  • 打赏
  • 举报
回复
Dim aa As String() Dim bb As String() aa = File.ReadAllLines("D:\1.txt") For i = 0 To aa.Length - 1 bb = Split(aa(i)) For k = 0 To bb.Length - 1 Console.WriteLine(bb(k)) Next Next Console.ReadKey()
devmiao 2013-12-31
  • 打赏
  • 举报
回复
Split(VbCrLf) 或者用File.ReadAllLines
这是第六版的介绍《ASP.NET 4入门经典:涵盖C#和VB.NET(第6版)》内容简介:ASP.NET是.NET Framework的一部分,用于构建内容丰富的动态Web站点。其最新的版本ASP.NET 4对上一版进行了许多改进,包括增强了Web窗体,并添加了jQuery的支持。《ASP.NET 4入门经典:涵盖C#和VB.NET(第6版)》循序渐进,逐步讲解了如何使用ASP.NET 4构建内容丰富的Web站点,并提供了大量使用C#和VB的示例。通过实际动手练习,您将学到关于构建Web站点的第一手信息,同时能够深刻理解在浏览器中查看ASP.NET 4页面时,后台到底发生了什么。 这是第七版,也就是本源码书的介绍 The ultimate programming guide to ASP.NET 4.5, by popular author and Microsoft MVP Imar Spaanjaars Updated for ASP.NET 4.5, this introductory book is filled with helpful examples and contains a user-friendly, step-by-step format. Written by popular author and Microsoft ASP.NET MVP Imar Spaanjaars, this book walks you through ASP.NET, Microsoft's technology for building dynamically generated web pages. This edition retains the highly accessible approach to building the Planet Wrox website example, an online community site featuring product reviews, picture sharing, bonus content for registered users, and more. Contains the comprehensive guide to the latest technology additions to ASP.NET 4.5 Shows how to build basic ASP.NET web pages and configure their server Includes information on how to add features with pre-built server controls Reveals how to design pages and make them consistent Contains the information needed for getting user input and displaying data Beginning ASP.NET 4.5 in C# and VB uses Spaanjaars's distinct writing style to put you at ease with learning ASP.NET 4.5.
☆ 资源说明:☆ [Wrox] ASP.NET 4.5 入门经典 (C# & VB 语言实现) (英文版) [Wrox] Beginning ASP.NET 4.5 in C# and VB (E-Book) ☆ 图书概要:☆ The ultimate programming guide to ASP.NET 4.5, by popular author and Microsoft MVP Imar Spaanjaars Updated for ASP.NET 4.5, this introductory book is filled with helpful examples and contains a user-friendly, step-by-step format. Written by popular author and Microsoft ASP.NET MVP Imar Spaanjaars, this book walks you through ASP.NET, Microsoft's technology for building dynamically generated web pages. This edition retains the highly accessible approach to building the Planet Wrox website example, an online community site featuring product reviews, picture sharing, bonus content for registered users, and more. Contains the comprehensive guide to the latest technology additions to ASP.NET 4.5 Shows how to build basic ASP.NET web pages and configure their server Includes information on how to add features with pre-built server controls Reveals how to design pages and make them consistent Contains the information needed for getting user input and displaying data Beginning ASP.NET 4.5 in C# and VB uses Spaanjaars's distinct writing style to put you at ease with learning ASP.NET 4.5. ☆ 出版信息:☆ [作者信息] Imar Spaanjaars [出版机构] Wrox [出版日期] 2012年11月06日 [图书页数] 888页 [图书语言] 英语 [图书格式] PDF 格式

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧