VB中让文本框显示文本文件内容
VB题:窗体上有一个Drivelestbox控件Drive1,一个Dirlistbox控件Dir1,一个Filelistbox控件File1,一个Combo1控件,一个T...
VB题:窗体上有一个Drivelestbox控件Drive1,一个Dirlistbox控件Dir1,一个Filelistbox控件File1,一个Combo1控件,一个TEXT控件,要求在用户选择DRIVE1控件中的驱动器后,Dri1控件中的目录随之改变,当Dir1中的目录改变后File1控件中的文件随之改变,Combo1内容改动时File1文件类型过滤成TXT,当选定File1中文本文件时在Text1中显示文件内容,编写此程序
当选定File1中文本文件时在Text1中显示文件内容,这个不会,请老师指导,请看图片
这是我写的,哪些需要改变
Private Sub Combo1_Click()
File1.Pattern = "*.txt"
End Sub
Private Sub Dir1_Change()
ChDir Dir1.Path
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
ChDrive Drive1.Drive
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Text1.Text = File1.FileName
End Sub
Private Sub Form_Load()
Combo1.AddItem "*.txt"
End Sub 展开
当选定File1中文本文件时在Text1中显示文件内容,这个不会,请老师指导,请看图片
这是我写的,哪些需要改变
Private Sub Combo1_Click()
File1.Pattern = "*.txt"
End Sub
Private Sub Dir1_Change()
ChDir Dir1.Path
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
ChDrive Drive1.Drive
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Text1.Text = File1.FileName
End Sub
Private Sub Form_Load()
Combo1.AddItem "*.txt"
End Sub 展开
2个回答
展开全部
Private Sub Combo1_Click()
File1.Pattern = combo1.text
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1
End Sub
Private Sub File1_Click()
Open File1.Path & "\" & File1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, temp
str1 = str1 & temp & vbCrLf
Loop
Close #1
Text1.Text = str1
End Sub
Private Sub Form_Load()
Combo1.AddItem "*.txt"
End Sub
File1.Pattern = combo1.text
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1
End Sub
Private Sub File1_Click()
Open File1.Path & "\" & File1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, temp
str1 = str1 & temp & vbCrLf
Loop
Close #1
Text1.Text = str1
End Sub
Private Sub Form_Load()
Combo1.AddItem "*.txt"
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |