vb.net中怎么让label控件按照txt中的格式读取
就是说我用VB.NET,label控件要读取txt文本的内容,但是读出来的不是txt里面的格式,怎样才能按照txt文件的格式读出来...
就是说我用VB.NET ,label控件要读取txt文本的内容,但是读出来的不是txt里面的格式,怎样才能按照txt文件的格式读出来
展开
2个回答
展开全部
如下代码即可:
Imports System.IO
Imports System.Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = ""
Dim sw As New StreamReader("D:\1.txt", Encoding.Default)
Do Until sw.Peek < 0
Label1.Text += sw.ReadLine + vbCrLf
Loop
sw.Close()
End Sub
End Class
Imports System.IO
Imports System.Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = ""
Dim sw As New StreamReader("D:\1.txt", Encoding.Default)
Do Until sw.Peek < 0
Label1.Text += sw.ReadLine + vbCrLf
Loop
sw.Close()
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询