vb保存数据问题,选择路径保存
我建立了个list1 drive1 dir1 向list里面添加了几行数字,希望通过选择dir1中的文件夹“新建文件夹2”,把list1中的数字保存在新建文件夹2中去,用的写入语言是input,并且保存为doc文档,但我不会获得新建文件夹2的路径。我的已有程序为:Dim fs As New FileSystemObject, dr As Drive, fl As Folder, s As String
Private Sub Command1_Click()
Set fl = fs.GetFolder(Dir1.Path)
ms = "新建文件夹名:"
ms = ms & Chr(13) & Chr(13) & "当前文件夹是:"
a = InputBox(ms & fl.Path, "新建", "新建文件夹")
If Len(Trim(a)) <> 0 Then Set fl = fs.CreateFolder(a)
Dir1.Refresh
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
n = Form1.List1.ListCount - 1
Open \数据.doc For Output As #1
For i = 1 To n
Print #1, Form1.List1.List(i)
Next i
End Sub
Private Sub Dir1_Change()
ChDir Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error GoTo 100
Dir1.Path = Drive1.Drive
ChDrive Drive1.Drive
ChDir Dir1.Path
100
MsgBox ("驱动器无效!!大哥!")
End Sub
红字部分是我想选择的路径,怎么从dri1中获得并将数据存入这个文件夹呢?大侠们拜托了!
[解决办法]
可以用 另外一个控件 Microsoft common dialog control 6.0
commondialog
可以直接得到filename
或者用你的方法 dir1.path & "新建文件夹2" & fliename 'filename为你新建的DOC文件名
[解决办法]
Dir1.Path & "\数据.doc"
[解决办法]