|
-
Jun 15th, 2010, 10:37 AM
#1
Thread Starter
New Member
Creating a Text File
Hi, just found this forum!! looks to be alot of great info here! looking forward to reading thru and learning more!
So i've been writing a program the last few days. i can create a text file and write to it and stuff. but i'm trying to write an application for logging data. I need to test these boxes in work (power distribution boxes) and i want to write a program to log the data from the test results. I can create a text file but im having trouble with getting it named properly. i want the text file to be named like this
Type, Date time, serial number.
type would be say...K5
for date and time i'm using the "Now" function.
serial number would be something like SN001
so the text file should be saved like this,
K5, 15/06/10 4:25 PM SN001
I appologise if this code looks really messy! i usually try to keep it tidy and readable but i have been cuttin and pastin for the last few hours now so it could prob be tidied up!
Code:
Private Sub Form_Load()
Dim filelocation As String
Dim FilePath As String
Dim Box As String
Dim TestDate As Date
FilePath = "C:\xyz"
End Sub
___________________________________
Private Sub Option1_Click()
Dim FileName As String
Box = "K5"
TestDate = Now
FilePath = "C:\xyz
FileName = Box + ", " + TestDate + ".txt"
filelocation = FilePath + FileName
Open filelocation For Append As #1
Print #1, Text1.Text
Close #1
End Sub
Thats how i tried to write it. i tried changing the code a lot and results were as follows, none were what i was lookin for! I either ended up with these or error 13!
K5, val(TestDate)Date.txt
K5, val(TestDate)Date.txt
K5, 150610.txt
K5, .txt
and a reminder again of what i am aiming for
K5, 15/06/10 4:25 PM SN001
Thanks for those who take the time to read, its very much appreciated! any suggestions are welcome! if any more info is needed let me know!
thanks and Regards,
Dean
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
|