|
-
Feb 12th, 2000, 07:11 AM
#1
Thread Starter
New Member
i want visual basic to require some files to be in a dir. what is the code for this.
also i need code to have vb get some text from a text file like get text after the word ex. here and stop getting it at the word ex. there then take it into another text file and insert the text after the line ex. hope some can help.
Can someone please help me with this i would appreciate it alot
-
Feb 12th, 2000, 07:15 PM
#2
Member
Here is a way to check for the existance of a file:
'
' fs - File System Object
' f - File / Folder
'
Dim fs, f
'
'
Public Function DoesFileExist(Path As String) As Boolean
Set fs = CreateObject("Scripting.FileSystemObject")
DoesFileExist = fs.FileExists(Path)
End Function
'
'
if DoesFileExist(app.path & "\SomeFile.ext")=false then End
'
-
Feb 13th, 2000, 05:17 PM
#3
Frenzied Member
An easier way to check for the existance of a file;
Function FileExists(ThisFile As String) As Boolean
On Error GoTo Doesnt
Dim fHandle As Integer
fHandle = FreeFile
Open ThisFile For Input As #fHandle
Close #fHandle
FileExists = True
Exit Function
Doesnt:
FileExists = False
End Function
Then use
If FileExists("the file") Then....
Else
....
Endif
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
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
|