码迷,mamicode.com
首页 > 其他好文 > 详细

Visual Basic 中读取逗号分隔的文本文件

时间:2019-12-18 15:11:32      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:ping   limited   microsoft   from   eve   comm   span   director   ali   

TextFieldParser 对象提供一种可以轻松而高效地分析结构化文本文件(如日志)的方法。 TextFieldType 属性用于定义文件是带分隔符的文件还是具有固定宽度文本字段的文件。

 

Dim currentRow As String()
   While Not MyReader.EndOfData
      Try
         currentRow = MyReader.ReadFields()
         Dim currentField As String
         For Each currentField In currentRow
            MsgBox(currentField)
         Next
         Catch ex As Microsoft.VisualBasic.
                     FileIO.MalformedLineException
           MsgBox("Line " & ex.Message &
           "is not valid and will be skipped.")
     End Try

https://docs.microsoft.com/zh-cn/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-text-files-with-multiple-formats
https://docs.microsoft.com/zh-cn/dotnet/visual-basic/developing-apps/programming/drives-directories-files/how-to-read-from-comma-delimited-text-files

Visual Basic 中读取逗号分隔的文本文件

标签:ping   limited   microsoft   from   eve   comm   span   director   ali   

原文地址:https://www.cnblogs.com/icaowu/p/12059478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!