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
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.
Form1.rtb.SaveFile App.Path & ("\[ " & Format(Time, "hh-mm-ss") & " ] " & "SavedChat.txt")
thx
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.
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?
Dim YOURFILENAME as String
YOURFILENAME = "ChannelLog.txt"
Open App.Path & YOURFILENAME for Append as #1
Print #1, TEXTTOPRINT
Close #1
There you go.
Better to make YOURFILENAME a Const unless you'll be modifying it at runtime. Also, you named it like a constant -- all-uppercase name.
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"
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