第一个问题 如何判断一个文件是否存在?/ 比如d:\a.txt 是否存在 如果不存在就创建 
第二个问题  我想把我最近打开的文件路径存到一个文本文件中 我用的
open app.path + "\"+ "a.txt" for output as #1
for i=1 to 5 
if jl(i).visble =true then 
print #1 jl(i).caption
end if
close #1
这样可以把jl(i)中的数据一行行的写进去吗/? 
我写了一便 但是第二便就不行了 请各位高手指教 最好能给出代码!! 

解决方案 »

  1.   


     if dir("d:\a.txt")<>"" then  
       存在
      

  2.   

    第一个问题:
        If Dir("d:\aa.txt") = "" Then
           MsgBox "文件不存在"
        Else
            MsgBox "文件已存在"
        End If
    第二个问题没看懂你想干啥
      

  3.   

    '第二个问题J1()是什么控件数组吗?没有必要这样使用,直接写就成了。
    可以直接定义一个数组来保存最近打开的文件及路径。
    dim strUrl as string
    strUrl=app.path & "\" & "ABC.txt"
    open app.path + "\"+ "a.txt" for output as #1
    print #1,strUrl
    close #1
      

  4.   

    Open App.Path + "\" + "a.txt" For Output As #1
    For i = 1 To 5
    If jl(i).visble = True Then
    Print #1, jl(i).Caption
    End If
    next 
    Close #1以上的语句没有问题,只是每遍都会覆盖以前的------------------------------------
    如果你要追加数据,可使用Open "c:\a.txt" For Append As #1
    For i = 1 To 5
            Print #1, i
    Next
    Close #1
    请看文件操作的文章
      

  5.   

    各位大哥 我是要做一个动态菜单 在load时候读入 unload时候写入 还有个问题没说啊 就是如果不存在就创建 我不想用fso 请各位大哥指点一二
      

  6.   

    这是一个将文件的内容写入到菜单中时间
    发生了一个问题 写到菜单上的的东西总是带上 ""  这个东西 我不想要 怎么搞 
    Dim i As Integer
    i = 1
    Dim buf As String
    Open App.Path + "\" + "f.txt" For Input As #1
    Do While Not EOF(1)
    Line Input #1, buf
    If buf <> "" Then
    jl(i).Caption = buf
    jl(i).Visible = True
    i = i + 1
    End If
    If i > 4 Then
    Exit Sub
    End If
    Loop
    Close #1
      

  7.   

    使用print语句,不会带上"",使用Write语句,它会给每个字符串加上"".