我想当程序运行后就会自动向程序所在的当前的这个目录里新建一个文件或做别的事了,请问用什么代码呢

解决方案 »

  1.   

    程序当前路径:App.Path
    新建文件夹函数:mkdir
      

  2.   

    第一种方法
    先引用 Microsoft Scripting RuntimeOption ExplicitPrivate Sub Command1_Click()
        Dim fs As New FileSystemObject
        Dim fl As Folder
        fl = fs.GetFolder(App.Path)
        fl.CreateTextFile ("A.txt")
    End Sub
      

  3.   

    第二种方法Private Sub Form_Load()
        Open App.Path & "A.txt" For Output Access Write As #1
            Print #1, "fff"
        Close #1
    End Sub
      

  4.   

    程序当前路径:App.Path
    文件夹及文件操作用 FileSystemObject
         如建目录:
          dim fso 
          set fso=createobject(scripting.filesystemobject)
          If Not Fso.FolderExists(folderpath) Then
                Fso.CreateFolder (folderpath)
           End If