显示文本

来源:百度知道 编辑:UC知道 时间:2024/06/08 06:12:40
在窗体上放一个Button,6个Textbox,点按钮弹出打开对话框,打开文本文件,文本文件内容分6行,每个Textbox中分别显示每行的内容,如何实现?
用CommonDialog打开文件

怪我眼花……没看清要求。。
答案已经做了修改,请查看。
============
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

Option base 1
Private Sub Command1_Click()
dim a, s as string
dim x()
Commondialog1.Showopen
if commondialog1.filename<>"" then
open commondialog1.filename for input as #1
do while not eof(1)
line input#1,a
s= s & a
loop
x=split(s,vbcrlf)
for i=1 to 6
text1(i).text=x(i)
next i

白木道人
s=s&a
s中并没vbcrlf
用split分不出来
应该是s = iif(s="" ,a ,s & vbcrlf & a)

新建1个tex