vb.net读数据文件 vb读取文件内容( 二 )


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String = "E:\User Documents\Master\My Documents\电子阅读\股票\table2.csv"
Using Recrods As New Microsoft.VisualBasic.FileIO.TextFieldParser(fileName) '建立TextFieldParser对象
'MyReader.TextFieldType = FieldType.Delimited
Recrods.SetDelimiters(",") '把字段分隔符设置为","
Dim curRow() As String
Do Until Recrods.EndOfData
curRow = Recrods.ReadFields() '读取记录行,返回字符串数组 , 所以不同字段类型需要自己转换 。
Debug.Print(Join(curRow, vbTab))
Loop
End Using
End Sub
VB.net窗体设计中,如何读取.txt文件中的数据?1、新建一个标准的VB EXE工程,只有一个Form,Form上有两个按钮:Command1和Command2 。
2、双击Command1添加如下代码
Private Sub Command1_Click()
Dim strFileAs String
Dim intFileAs Integer
Dim strDataAs String
strFile = "c:\学生成绩.txt"
intFile = FreeFile
Open strFile For Input As intFile
strData = https://www.04ip.com/post/StrConv(InputB(FileLen(strFile), intFile), vbUnicode)
Debug.Print strData
Close intFile
End Sub
3、按F8开始单步调试代码 , 点击Command1,进入单步调试功能,
4、多次按下F8或直接按下F5运行完成,就完成了读取文本文件内容并输出到立即窗口 。
【vb.net读数据文件 vb读取文件内容】关于vb.net读数据文件和vb读取文件内容的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读