VB Save text file with variable name

Started by
-1 comments, last by DaProgrammer 18 years, 7 months ago
Hi, i am using VB 6.0 and i want to save a text file using a varible as part of the file name. Here is what i currently have:

appPath = App.Path
If Right(appPath, 1) <> "\" Then appPath = appPath & "\"
' Get a free file number
FileNum4 = FreeFile
' Create mood.txt
Open appPath & "mood.txt" For Append As #FileNum4
' Write the contents to mood.txt
Print #FileNum4, mood; ","; FSOUND_Stream_GetTime(stream1)
' Close the file
Close FileNum4
However this creates a file called mood.txt. What i need is songTitle mood.txt where songTitle is a variable. songTitle is a String which usually looks something like this; C:\Documents and Settings\user\Desktop\song.mp3 So i want the file as C:\Documents and Settings\user\Desktop\song.mp3 mood.txt something like that. But using

Open appPath & songTitle & "mood.txt" For Append As #FileNum4
results in a bad filename error. Is there a way around this? Thanks

This topic is closed to new replies.

Advertisement