Jump to content
  • Advertisement
Sign in to follow this  
DaProgrammer

VB Save text file with variable name

This topic is 4768 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!