Sign in to follow this  

VB Save text file with variable name

This topic is 4488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites

This topic is 4488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this