监狱文化影视视频:VB的一个小问题。来帮帮我

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 20:29:56
在打开程序的 时候 先判断 D盘有没有名为1的文件夹。如果有什么也不执行 退出程序。

如果没有 就建一个 名为1的文件夹。

这个程序应该怎么写。哪位高手给我写个完整的。
第二次运行的时候 会有错误。

Function FileExists(FileName As String) As Boolean
On Error Resume Next
FileExists = Dir$(FileName) <> ""
If Err.Number <> 0 Then
FileExists = False
End If
On Error GoTo 0
End Function

Private Sub Form_Load()
If FileExists("D:\1") Then
END
Else
MkDir("D:\1")
End If

End Sub

手头没有VB,没法测试。不过应该没什么问题,你去试试吧。

If Len(Dir("d:\1", vbDirectory)) > 0 Then
Unload Me
Else
MkDir "d:\1"
End If