VB怎样把*.txt里的内容显示在text1中???急██████████████████████████████████████████████
home那个可以,但是不能按行输入,怎样才能按行输入啊?? 能帮我再改改吗
███VB把*.txt里的内容显示在text1中███
答案:2 悬赏:40 手机版
解决时间 2021-03-04 04:18
- 提问者网友:人生佛魔见
- 2021-03-03 17:23
最佳答案
- 五星知识达人网友:夜余生
- 2021-03-03 18:46
晕,代码是逐行读取的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
加一个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
全部回答
- 1楼网友:举杯邀酒敬孤独
- 2021-03-03 19:00
你好!
引用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
仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯