• Welcome to Valhalla Legends Archive.
 

Why wont this work?

Started by OuTLawZGoSu, January 13, 2004, 06:43 PM

Previous topic - Next topic

OuTLawZGoSu

I need to save a text file with this format in the name:
"  [<current time>] Saved Chat.txt   "

When I hit Save, the file doesent save.
What am I doing wrong?


Private Sub Save_Click()
Form1.rtb.SaveFile (App.Path & "[ " & Format(Time, "hh:mm:ss") & " ] " & "SavedChat.txt")
End Sub

Private Sub Load_Click()
Form8.cd1.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
Form8.cd1.ShowOpen
Form8.rtbload.LoadFile Form8.cd1.FileTitle
End Sub

K

One problem I see right of the bat is that you can't have colons in a file name. (or backslashes either, in case you're saving the date as well).  Try replacing them with dashes, commas, or periods.

OuTLawZGoSu

#2
Form1.rtb.SaveFile App.Path & ("\[ " & Format(Time, "hh-mm-ss") & " ] " & "SavedChat.txt")

thx

CrAzY

Eh, your doing it all wrong.  You need to open a txt file there should be a code for that.  I forget it off the top of my head.
CrAzY

K

Quote from: CrAzY on January 14, 2004, 07:41 AM
Eh, your doing it all wrong.  You need to open a txt file there should be a code for that.  I forget it off the top of my head.

Actually, the Richtextbox control has a save method which will save its contents to a file.  Why do things the long way when you can do it like he's doing it?

Newby

Dim YOURFILENAME as String
YOURFILENAME = "ChannelLog.txt"

Open App.Path & YOURFILENAME for Append as #1
Print #1, TEXTTOPRINT
Close #1


There you go.
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Stealth

Better to make YOURFILENAME a Const unless you'll be modifying it at runtime. Also, you named it like a constant -- all-uppercase name.
- Stealth
Author of StealthBot

Newby

#7
Well, I just put that there so he could copy/paste that and change the channel log name. :P

Unless you want me to o_O


Dim YOURFILENAME as String
becomes

Private Const YOURFILENAME = "ChannelLog.txt"
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Ersan

You need to include a backslash before your filename, after App.Path

Dim YOURFILENAME as String
YOURFILENAME = "\ChannelLog.txt"
Open App.Path & YOURFILENAME for Append as #1
Print #1, TEXTTOPRINT
Close #1