|
-
Sep 22nd, 2000, 05:08 AM
#1
Thread Starter
Junior Member
I have a query related to the above.
I want to do exactly as above to create a log file, but my problem is naming the file using a string made up of "backup" and the date, i.e. backup22.09.2000.txt.
I've tried:
strFileName = "backup" & Date & ".txt"
Open "C:\Temp\strFileName" For Output As #1 and
Open "C:\Temp\"strFileName"" For Output As #1
but neither work. Can you help me on the correct syntax please?
-
Sep 22nd, 2000, 05:15 AM
#2
Frenzied Member
Syntax:
Open "c:\temp\" & strFileName For Output As #1
Hope that helps.
-
Sep 22nd, 2000, 05:27 AM
#3
Thread Starter
Junior Member
Thank you for your reply mlewis. I've just tried that and i'm getting a "path not found" error. I should say i do have a C:\Temp directory... :-)
-
Sep 22nd, 2000, 05:32 AM
#4
_______
<?>
PetergUK ..don't use mm.dd.yyyy
[code]
Option Explicit
Private Sub Form_Load()
Dim x
x = Format(Now, "ddmmyyyy")
x = "C:\my documents\backup\" & x & ".txt"
Open x For Output As #1
Write #1, "OK"
Close
End Sub
[code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 22nd, 2000, 05:42 AM
#5
Thread Starter
Junior Member
That's great HeSaidJoe
Can you explain why yours works and mine doesn't?
-
Sep 22nd, 2000, 05:48 AM
#6
Hyperactive Member
Because a filename usually consists of name.extension, whereas your file name would have been day.month.extension or whatever. More than one dot, you see.
-
Sep 22nd, 2000, 05:51 AM
#7
Thread Starter
Junior Member
-
Sep 22nd, 2000, 06:37 AM
#8
_______
PetergUK
[code]
'actually it has nothing to do with .
'it is just bad practice to use characters in filenames
'the reason was in your writing of the variable
'
'your statement should create a file called C:\Temp\strFileName
'and not what was stored in strFileName
'
'Open "C:\Temp\strFileName" For Output As #1 and
should be
Open "C:\Temp\" & strFileName For Output As #1
[\code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 22nd, 2000, 08:49 AM
#9
Thread Starter
Junior Member
Thanks HeSaidJoe
It was the & that got me......
-
Sep 22nd, 2000, 09:34 AM
#10
Frenzied Member
Because a filename usually consists of name.extension, whereas your file name would have been day.month.extension or whatever. More than one dot, you see.
I don't think that's because of the dots, I think it displays dd/mm/yyyy
and you're not allowed to have /\<>~:?"|* in your filename.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 22nd, 2000, 09:41 AM
#11
Thread Starter
Junior Member
Thank everyone, i've now got it working nicely:
-----------------------------------------
Dim strFileName
NetUser
strFileName = Format(Now, "dd.mm.yyyy")
strFileName = "C:\temp\backup log " & strFileName& ".txt"
Open strFileName For Output As #1
Write #1, Time & " Application opened by " & NetUser
-------------------------------------------
By the way, when writing to the txt file, what's the difference between Write and Print? The help files don't seem to make a distinction.
-
Sep 22nd, 2000, 12:43 PM
#12
Fanatic Member
If you Write to the file then it will put whatever you write in quotes (""). But if you use Print then it will print without the quotes ("").
Hope that explains it for you,
D!m
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
|