Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this possible?

Status
Not open for further replies.

Terence

Technical User
Feb 22, 2001
30
US
Is there a way to save a text file with the computers date added to the end of the filename ? ie filename_2_24_01.txt
 
Yep,

Have a loot at the format() function, use that to build up your filename. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Hi Terence,

This sample should do what you want...

Create a form with two text boxes (Text1 and Text2) plus
a button (Command1) - I put a lot of thought into those names :>} Type a filename into Text1 and click the button.

NOTE: the code assumes a DOT between the prefix and suffix in the filename.

The code is tested and works.

Put this code on the button click event
=====================================
Private Sub Command1_Click()

If Not IsNull(Text1.Text) Then
Text2 = AddDateToFileName(Text1.Text)
End If

End Sub


Function AddDateToFileName(FileNameIn As String) As String
Dim intPos As Integer
intPos = InStr(FileNameIn, ".")

AddDateToFileName = Left(FileNameIn, intPos - 1) & "_" & _
Left(Date, 2) & "_" & _
Mid(Date, 4, 2) & "_" & _
Mid(Date, 7) & _
Mid(FileNameIn, intPos)

End Function
=====================================
HTH
 
This one's too easy:

MyFile = "filename" & Format$(now,"_mm_dd_yy.txt")

Hope this helps... They never have to knock if your door is always open.
 
Option Explicit
Dim file_name As String

file_name = App.Path
If Right$(file_name, 1) <> &quot;\&quot; Then file_name = file_name & &quot;\&quot;
file_name = file_name & &quot;bedrijf_&quot; & Format(Date, &quot;mm_dd_yy&quot;) & &quot;.txt&quot;
Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
Thanks for the help, i used Bigfoots example as it did just what i needed!

X-)
 
its Your Choose ,but where is the file ??? (app.path or C:\ or D:\ )

;-)

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
It is just formaltie and dont save a file !!!

MyFile = &quot;filename&quot; & Format$(now,&quot;_mm_dd_yy.txt&quot;)

kinds regards

Eric Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
Oopse, I forgot to give him a path, but then he did not ask for one, just the file name.
So I assumed he knew where he was putting it. They never have to knock if your door is always open.
 
the file ends up where ever i run thre program from. For now that is what i needed. I can now play with figuring out how to add the path. I have to do some of the work....

Thanks again for all the help (-:
 
I put all of my paths in an ini file. That way I don't ever have to recompile my program to change a path.
Some people put their paths in the registry. That's ok, but you have a much easer time editing an ini file with notepad.

MyFile = App.Path & &quot;\&quot; & &quot;filename&quot; & Format$(now,&quot;_mm_dd_yy.txt&quot;)

Hope this helps...

-G They never have to knock if your door is always open.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top