注册 登录
编程论坛 VB.NET论坛

求助如下代码怎么让文本框显示TXT内容,OpenFileDialog1

Roc_Chen 发布于 2019-07-18 16:20, 1542 次点击
OpenFileDialog1.Filter = "(*.txt)|*.txt"   
        OpenFileDialog1.ShowDialog()   
        Label3.Text = OpenFileDialog1.FileName
        TextBox1.Text =
这个 TextBox1.Text = 后面该写什么  才能让txt文本显示出来
如果我要筛选哪些可以显示哪些不可以显示呢  
求大佬告知
1 回复
#2
厨师王德榜2019-07-18 16:32
供参考:
程序代码:
            ' 利用StreamReader类读取文本内容
            Dim sr As New StreamReader(File.OpenRead(strCsvName.Trim), autoEncode)
            Try
                        Do While sr.EndOfStream = False
                            strTxtRow = sr.ReadLine()
                            DTtxt.Rows.Add(strTxtRow)
                            result += 1
                        Loop

                '//设置光标的位置到文本尾
                Me.RTxt1.Select(Me.RTxt1.TextLength, 0)
                '//滚动到控件光标处
                Me.RTxt1.ScrollToCaret()
            Catch ex As Exception
                MsgBox("失败!" & vbCrLf & "========详情========" & vbCrLf & ex.Message, vbOKOnly, "提示:")
            Finally
                sr.Close()
                sr.Dispose()
                Me.Cursor = Cursors.Default
            End Try
1