怎么用 vb打开记事本

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

我的代码程序如下:
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
File1.Pattern = "*.txt"
End Sub

老师让我们用vb程序打开记事本,要怎么写代码呢
请高手指点啊

打开记事本:
正常的系统中,只要用shell "notepad.exe"就可以。可以在notepad.exe后面加上一个空格,再加上要打开的文本文件的路径。

另外还有一招适用所有文件类型的:
利用CMD命令:
shell "cmd.exe /c start c:\abc.txt"
shell "cmd.exe /c start c:\abc.doc"
shell "cmd.exe /c start http://www.fj543.cn"
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-12-19
Private Sub Dir1_Click()
    File1.Path = Dir1.Path
End Sub
Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub
'我的代码程序如下:
Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
    File1.Pattern = "*.txt"
End Sub

Private Sub File1_DblClick()
    Dim fName As String
    fName = File1.Path & "\" & File1.FileName
    fName = Replace(fName, "\\", "\")
    Shell "notepad " & fName, 1
End Sub本回答被提问者采纳
第2个回答  推荐于2016-10-27
直接打开记事本
Shell "notepad.exe", vbNormalFocus
打开某个txt文件
Shell "notepad.exe c:\文件.txt", vbNormalFocus

后面的vbNormalFocus是打开后窗体的状态,编写代码时会有提示。

第3个回答  2007-12-19
Private Sub File1_DblClick()
'代码太长 我用& _ 格式分了三行 正确应该是把后边的 _ 号去掉 合在一行的
'其中的iif()是以防止返回的File1.Path结尾不是以/或\结束时产生错误的处理
Shell "notepad.exe """ & _
IIf(Right(File1.Path, 1) <> "\" And Right(File1.Path, 1) <> "/", File1.Path & "\", File1.Path) & _
File1.FileName & """""", vbNormalFocus
End Sub
第4个回答  2007-12-19
Shell "notepad.exe " + "?" '? 代表你要打开的文本文件