███VB把*.txt里的内容显示在text1中███

来源:百度知道 编辑:UC知道 时间:2024/05/11 04:17:14
VB怎样把*.txt里的内容显示在text1中???急██████████████████████████████████████████████
home那个可以,但是不能按行输入,怎样才能按行输入啊?? 能帮我再改改吗

晕,代码是逐行读取的Line Input #1, Intext
加一个commondialog控件,用text2显示文件内容,text1显示文件名.

Private Sub Command1_Click()
Common1.Filter = "txt文件(*.txt)|*.txt"
Common1.ShowOpen
If Common1.FileName = "" Then
Exit Sub
Else
Text2.Text = ""
Text1.Text = Common1.FileName
Open (Common1.FileName) For Input As #1
Do While Not EOF(1)
Line Input #1, Intext
Text2.Text = Text2.Text & Intext
Loop
Close #1
End If
End Sub

引用Microsoft Scripting Runtime

dim a as new filesystemobject
dim b as object

Sub Form_Load()
Set b=a.opentextfile("*.txt",forreading)
text1.text=b.readall
end sub