VB打开TXT文件问题

来源:百度知道 编辑:UC知道 时间:2024/06/14 18:57:11
Open App.Path & "\aa.txt" For Output As #1
Print #1, "123"
Close #1
以上只是后台打开文件,并写入内容再关闭文件,
我加了一个查看源文件按钮,点击后直接运行该文本,评估问如何写?
Private Sub Command1_Click() '查看源文件件
............ '运行该文本,查看文本内容
End Sub

朋友,试试下面代码。。这个是用记事本 打开源文件 注:notepad 后面有个空格

'需要控件:command1
Private Sub Command1_Click()
Shell "notepad " & App.Path & "\aa.txt", vbNormalFocus
End Sub

Shell "explorer.exe "&文件路径(包括文件名和扩展名) , vbNormalFocus
理论上这句代码可以打开任何系统已知类型文件
Private Sub Command1_Click()
dim FilePath as String
FilePath =App.Path & "\aa.txt"
Shell "rundll32.exe url.dll,FileProtocolHandler " & FilePath, vbNormalFocus
End Sub

shell "notepad.exe "+path,vbnormal

大概是文件的问题