|
-
Jun 24th, 2000, 10:57 AM
#1
Thread Starter
Frenzied Member
I forgot how to do this, but I want to see if a folder already is alread there, and if not, I want to create so can someone please fix the code for me:
Code:
if (the folder is already there) then
Open "C:\dimas password\01.dat" For Output As #1
Write #1, txtfn.Text, txtln.Text
Close #1
ELSE: MkDir "C:\dimas password\"
Open "C:\dimas password\01.dat" For Output As #1
Write #1, txtfn.Text, txtln.Text
Close #1
End If
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:10 AM
#2
If Dir("C:\dimas password\") <> "" Then ...
"It's cold gin time again ..."
Check out my website here.
-
Jun 24th, 2000, 11:12 AM
#3
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:12 AM
#4
Hyperactive Member
object.FolderExists(folderspec)
where object is the name of a FileSystemObject and folderspec is the folder name.
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 11:17 AM
#5
Thread Starter
Frenzied Member
I have another problem:
Code:
If Dir("C:\dimas password\") <> "" Then
Open "C:\dimas password\01.dat" For Output As #1
Write #1, txtfn.Text, txtln.Text
Close #1
Else:
MkDir "C:\dimas password\"
Open "C:\dimas password\01.dat" For Output As #1
Write #1, txtfn.Text, txtln.Text
Close #1
End If
the problem is that an error comes up when I run the program, I click debug and the yellow thign is pointing to where it ways:
Code:
MKDIR "C:\ dimas password\"
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:21 AM
#6
Hyperactive Member
Here's why If Dir("C:\dimas password\") <> "" Then... doesn't wo
cause if c:\dimas password\ exist but is empty, then it returns "" as well, so going to MkDir would crash it.
It also returns "" is the folder contains hidden files.
Use the method mentioned above.
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 11:25 AM
#7
Thread Starter
Frenzied Member
Re: Here's why If Dir(
I don't think that I quite under stand what you wrote above, can you please put it so that it works in my case:
object.folderexists(something)
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:30 AM
#8
Hyperactive Member
How to create fso
btw... to create a FileSystemObject use:
Code:
Set fso = CreateObject("Scripting.FileSystemObject")
then
Code:
If fso.FolderExists(anyFolder) Then
Good luck
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 11:34 AM
#9
Thread Starter
Frenzied Member
Re: How to create fso
where do I put this:
Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Also, for how many years have you been learning VB (if not a secret)
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:40 AM
#10
Hyperactive Member
You can put the declaration wherever you want, preferably somewhere where it would run before fso is called. Like a module or Form_load or something..
And I've been programming in vb since 89, so I guess that makes it 11 years..
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 11:45 AM
#11
Thread Starter
Frenzied Member
Ok, thanks, it worked!!!
WOW you've been programming for 11 years WOW!!!!
do you work at some big company or something?
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:48 AM
#12
I stand corrected. The FSO, not the Dir function was the way to go for this problem.
"It's cold gin time again ..."
Check out my website here.
-
Jun 24th, 2000, 11:49 AM
#13
Thread Starter
Frenzied Member
one more question, how do I check if a file already exists
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 11:56 AM
#14
Hyperactive Member
You use FileExists
It's the same
Just replace FolderExists with FileExists
(and a filename within parentesis)
object.FileExists(filenamewithpath)
I'm not employed no I'm just still a student... but soon maybe..
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 11:57 AM
#15
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jun 24th, 2000, 12:06 PM
#16
Hyperactive Member
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
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
|