|
-
Feb 19th, 2005, 02:00 AM
#1
Thread Starter
Admodistrator
FileExists:
Just wondering, how do you check if a directory exists? i thought it was like
VB Code:
Private Sub Form_Load()
If FileExists(App.Path & "\yay.dir") Then
Print vbNullString
Else
MsgBox ("File needs to be ..")
Unload Me
End If
End Sub
but that doesnt work.
-
Feb 19th, 2005, 02:04 AM
#2
Re: FileExists:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim f As String
f = Dir("*.vbp", vbNormal)
If f <> "" Then Beep
End Sub
This beeps as its in my VB98 folder. Supply your folder name, and file name to check on the file existance.
-
Feb 19th, 2005, 02:07 AM
#3
Thread Starter
Admodistrator
Re: FileExists:
where do i change the filename? i want it to check if a dir exists
-
Feb 19th, 2005, 02:27 AM
#4
Addicted Member
Re: FileExists:
VB Code:
Dim fso As New FileSystemObject
If fso.FolderExists("C:\xyz") Then
'Yes
Else
'No
End If
 Originally Posted by |2eM!x
Just wondering, how do you check if a directory exists? i thought it was like
VB Code:
Private Sub Form_Load()
If FileExists(App.Path & "\yay.dir") Then
Print vbNullString
Else
MsgBox ("File needs to be ..")
Unload Me
End If
End Sub
but that doesnt work.
-
Feb 19th, 2005, 02:33 AM
#5
Re: FileExists:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim f As String
f = Dir("c:\windows", vbDirectory)
If f <> "" Then Beep
End Sub
as you type DIR("", you are prompted with intellisence prompts for the choices you can use. there are about 7 of them
you can use + to combine them
-
Feb 19th, 2005, 02:34 AM
#6
Thread Starter
Admodistrator
Re: FileExists:
"user-defined type not defined"
edit**
yay thanks dg, youve saved my night
-
Feb 19th, 2005, 02:40 AM
#7
Re: FileExists:
need a reference to file scripting object
-
Feb 19th, 2005, 02:41 AM
#8
Addicted Member
Re: FileExists:
you need to add Microsoft Scripting Runtime for that.
any way, you already got a simple one your hands.
 Originally Posted by |2eM!x
"user-defined type not defined"
edit**
yay thanks dg, youve saved my night 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|