Open App.Path + "\1.txt" For Output As #1 '打开文件写入的内容Close #1 '关闭文件
什么叫“用vb打开txt文件”,你是要读取还是要调用记事本显示?
Option Explicit Dim strFile As String Dim strMemo As String Dim intFileNum As Integer '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '过程功能: '功能描述:Input方式读入文件 '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Private Sub btnInput_Click() On Error GoTo errSub strMemo = "" intFileNum = FreeFile(0) Open strFile For Input As #intFileNum Input #intFileNum, strMemo Close #intFileNum txtMemo.Text = strMemo Exit Sub errSub:End SubPrivate Sub Form_Load() strFile = App.Path & "\111.txt" strFile = "E:\abc" & StrConv(StrConv("?", vbFromUnicode), vbUnicode) & "cde.text" End Sub
Dim strFile As String
Dim strMemo As String
Dim intFileNum As Integer
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:
'功能描述:Input方式读入文件
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Private Sub btnInput_Click()
On Error GoTo errSub
strMemo = ""
intFileNum = FreeFile(0)
Open strFile For Input As #intFileNum
Input #intFileNum, strMemo
Close #intFileNum
txtMemo.Text = strMemo
Exit Sub
errSub:End SubPrivate Sub Form_Load()
strFile = App.Path & "\111.txt"
strFile = "E:\abc" & StrConv(StrConv("?", vbFromUnicode), vbUnicode) & "cde.text"
End Sub