vb 用CommonDialog1打开一个txt文件,并把它复制到text1.text中。

来源:百度知道 编辑:UC知道 时间:2024/05/12 17:08:02
是,我不会用CommonDialog1 打开选中的文件。在某文件夹里有一个txt文件。想把它调到程序里。

首先用
CommonDialog1.ShowOpen
选中你需要的那个txt文件
然后用
CommonDialog1.FileName
得到路径以及文件名
就可以打开文件处理了

下面的代码供参考
Dim temp As String
Dim all As String
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Input #1, temp
all = all & temp & Chr(13) & Chr(10)
Loop
Close #1
Text1.Text = all

楼上你这个问题是想问什么???代码??