网站首页 > 文章中心 > 其它

vb.net读取文本值_VB.NET怎么读取文件的内容

作者:小编 更新时间:2023-09-06 22:07:57 浏览量:375人看过

如何用vb.net编写读取txt内容的代码?

代码如下:

'写文本文件

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'创建(写入)一个文本文件

Dim MyStream As New System.IO.FileStream(Application.StartupPath "\Ssk.txt", System.IO.FileMode.Create)

Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.Default)

MyWriter.WriteLine(TextBox1.Text)

MyWriter.Flush()

MyWriter.Close()

MyStream.Close()

End Sub

'读文本文件

'读取一个文本文件

MyReader.Close()

气斜射入水或其他介质,折射光线与入射光线法线在

VB.net 读取文本文件?

①.、实现上传按钮方法代码.

VB.net窗体设计中,如何读取.txt文件中的数据?

Private Sub Command1_Click()

Dim strFile? ? ?As String

Dim intFile? ? ?As Integer

Dim strData? ? ?As String

strFile = "c:\学生成绩.txt"

intFile = FreeFile

Open strFile For Input As intFile

strData = StrConv(InputB(FileLen(strFile), intFile), vbUnicode)

Debug.Print strData

Close intFile

VB.net 读取文本文件

Imports?System.IO

Public?Class?Form1

Private?Sub?Form1_Load(sender?As?System.Object,?e?As?System.EventArgs)?Handles?MyBase.Load

Dim?sr?As?New?StreamReader("d:\test.csv")

Do?Until?sr.EndOfStream

Dim?str?As?String?=?sr.ReadLine

Dim?s()?As?String?=?str.Split(",")

ListBox1.Items.Add(s(0))

Loop

arr1?=?CType(a1.ToArray(GetType(Integer)),?Integer())

sr.Close()

End?Sub

End?Class

以上就是土嘎嘎小编为大家整理的vb.net读取文本值相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章