显示文本内容

来源:百度知道 编辑:UC知道 时间:2024/09/23 10:06:32
点击一个按钮,弹出打开文件对话框,打开文本文件,将文本文件中的内容分别输入到几个文本框中,是否可以做到?
文本文件的内容分六行,在窗体上放六个文本框,分别显示文件的内容,如何实现?

Private Sub Command1_Click()
CommonDialog1.Filter = "文本文件|*.txt"
CommonDialog1.ShowOpen
Dim s As String
Open CommonDialog1.FileName For Input As 1
Line Input #1, s
Text1.Text = s
Line Input #1, s
Text2.Text = s
Line Input #1, s
Text3.Text = s
Line Input #1, s
Text4.Text = s
Line Input #1, s
Text5.Text = s
Line Input #1, s
Text6.Text = s
Close
End Sub

一楼的不对!
可以
控件加上CommonDialog 6.0
并弄一个到窗体上
在单击按钮事件代码:
dim str1 as string
CommonDialog1.Showopen
open commondialog1.filename for input as #1
do while not eof(1)
line input #1,str1
text1.text=str1 & chr(13) & chr(10)
loop
close #1
text1.text=left(text1.text,len(text1.text)-2)

可以
+CommonDialog 6.0
在单击按钮事件代码:CommonDialog1.Showopen
然后在Text里写代码:Text1.text=commondialog1.filename

手机答题!不好叙说,有分没?

支持2 楼的,但是文件内容也应该有格式。