Feb 2nd, 2005, 10:04 PM
#1
Thread Starter
Hyperactive Member
help please [RESOLVED]
I have this code below
Private Sub Command1_Click()
Dim f1 As Integer, songpath As String, mp3path As String, f2 As Integer, i As Integer
VB Code:
mp3path = "C:\test\my_mp3s"
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2 ' if you don't need mp3.txt take out
f1 = FreeFile
Open mp3path & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
songname = Dir(mp3path & "\*.mp3") ' get first track
i = 1
While Not Len(songname) = 0
songpath = "<song path=""" & mp3path & songname & """ title=""" & songname & """/> "
Print #f1, songpath
Print #f2, songname ' for mp3.txt
Sleep 100 ' slight pause, needed
songname = Dir ' get next track
Wend
Print #f1, "</songs>"
Close
End Sub
this then prints this
<?xml version="1.0"?>
<songs>
<song path="C:\test\my_mp3s02-Never Say Goodbye.mp3" title="02-Never Say Goodbye.mp3"/>
</songs>
my question is - is there any way that this will work but remove the c:\test\ when written.
thanx
Last edited by robvr6; Feb 3rd, 2005 at 12:35 PM .
Reason: resolved
Feb 2nd, 2005, 10:08 PM
#2
Re: help please
Not quite sure I follow, but if you change your variable to the path you want
it will printout with that path. Also, you can use the app.path function to
append the current directory that your exe is located in.
VB Code:
mp3path = App.Path & "\my_mp3s"
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Feb 2nd, 2005, 10:14 PM
#3
Re: help please
Just take out the path. ( & mp3path & )
VB Code:
songpath = "<song path=""" songname & """ title=""" & songname & """/> "
Feb 2nd, 2005, 10:18 PM
#4
Thread Starter
Hyperactive Member
Re: help please
sorry shouldve been clearer it is just the path in the xml that I need to print like this <song path="my_mp3s\"artist="" title=""/>
<?xml version="1.0"?>
<songs>
<song path="my_mp3s\"artist="" title=""/>
</songs>
but all I can get is this
<?xml version="1.0"?>
<songs>
<song path="C:\test\my_mp3s02-Never Say Goodbye.mp3" title="02-Never Say Goodbye.mp3"/>
</songs>
Feb 2nd, 2005, 10:19 PM
#5
Re: help please
Yes, that will work but does the poster want no path at all and only the song title?
Guess we will have to wait and see
My eyes are getting tired. I missed that he didnt include a trailing backslash.
VB Code:
mp3path = App.Path & "\my_mp3s\"
'Original prints like this - "C:\test\my_mp3s02-Never Say Goodbye.mp3"
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Feb 2nd, 2005, 10:21 PM
#6
Re: help please
Then change your variable to how you want it to print.
You maen like that?
Or like this
VB Code:
songpath = "<song path=""" & mp3path & """ title=""" & songname & """/> "
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Feb 2nd, 2005, 10:29 PM
#7
Thread Starter
Hyperactive Member
Re: help please
I tried that but kept getting a path not found error, I thought this would be easy because I get it reading from the my_mp3s f older but it still prints the full path
Feb 2nd, 2005, 10:29 PM
#8
Re: help please
Oh, like that.
VB Code:
Dim mp3Path2 As String
mp3Path2 = "my_mp3s\"
songpath = "<song path=""" & mp3path & songname & """ title=""" & songname & """/> " 'Original
'New
songpath = "<song path=""" & mp3Path2 & """ title=""" & songname & """/> "
This way we are not changing the Open ... path for the file.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Feb 2nd, 2005, 10:33 PM
#9
Thread Starter
Hyperactive Member
Re: help please
do I need to replace the original with that or add to my original?
Feb 2nd, 2005, 10:40 PM
#10
Re: help please
replace it with this;
VB Code:
songpath = "<song path=""" & mp3Path2 & """ title=""" & songname & """/> "
I didn't think you wanted the path at all. I see you wanted them separated.
Feb 2nd, 2005, 10:45 PM
#11
Re: help please
Oh ya, and change title to artist.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Feb 2nd, 2005, 10:57 PM
#12
Re: help please
I don't see the artist info.
Feb 2nd, 2005, 11:01 PM
#13
Thread Starter
Hyperactive Member
Re: help please
Ive messed up somewhere here
Im getting
<?xml version="1.0"?>
<songs>
<song path="my_mp3s\" artist="02-Never Say Goodbye.mp3"/>
</songs>
when I need this.
<?xml version="1.0"?>
<songs>
<song path="my_mp3s/.mp3"artist="" title=""/>
</songs>
VB Code:
Private Sub Command1_Click()
Dim f1 As Integer, songpath As String, mp3path As String, f2 As Integer, i As Integer, mp3Path2 As String
mp3path = "C:\test\my_mp3s\"
mp3Path2 = "my_mp3s\"
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2 ' if you don't need mp3.txt take out
f1 = FreeFile
Open mp3path & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
songname = Dir(mp3path & "\*.mp3") ' get first track
i = 1
While Not Len(songname) = 0
songpath = "<song path=""" & mp3Path2 & """ artist=""" & songname & """/> "
Print #f1, songpath
Print #f2, songname ' for mp3.txt
Sleep 100 ' slight pause, needed
songname = Dir ' get next track
Wend
Print #f1, "</songs>"
Close
End Sub
Feb 2nd, 2005, 11:05 PM
#14
Re: help please
which field is the artist? Just substitute yours for mine in CAPS
VB Code:
songpath = "<song path=""" & mp3Path2 & """ artist=""" & ARTIST & """ title=""" songname & """/> "
Feb 2nd, 2005, 11:12 PM
#15
Thread Starter
Hyperactive Member
Re: help please
I get the artist using a more complex version but the priciple is the same so I thought it would be easier to explain with this smaller example
Attached Files
Feb 2nd, 2005, 11:30 PM
#16
Re: help please
that's better. you should be able to use the artist field. Just substitute it where I have the CAPS above.
Feb 2nd, 2005, 11:34 PM
#17
Thread Starter
Hyperactive Member
Re: help please
so if I add those ammendments to that code then should that do the trick?
Feb 2nd, 2005, 11:41 PM
#18
Re: help please
Yes. the artist info wasn't in the first post. I see that it is in the code. Providing that it is correct, then it should work. If it doesn't, post some code.
Feb 2nd, 2005, 11:47 PM
#19
Thread Starter
Hyperactive Member
Re: help please
Im gettin a syntax error now - Its probly blindingly obvious but my eyes are goin and gettin tired lol
VB Code:
Private Sub Command2_Click()
Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer
Dim Artist As String, SongName As String, artname As String, fname As String, mp3Path2 As String
Dim mytag As Boolean
mp3path = "C:\Program Files\mgamerz\my_mp3s\"
xmlpath = "C:\program files\mgamerz\ "
mp3Path2 = "my_mp3s\"
SongName = Dir(mp3path & "\*.mp3")
fname = mp3path & SongName
With Form4
While Not Len(SongName) = 0
' Artist = GetMP3Tag(fname)
If Not i = 0 Then
Load .Label1(i): Load .Text1(i)
.Label1(i).Top = .Label1(i - 1).Top + 350
.Text1(i).Top = .Text1(i - 1).Top + 350
.Label1(i).Visible = True: .Text1(i).Visible = True
End If
.Label1(i) = SongName
mytag = GetMP3Tag(fname)
.Text1(i) = RTrim(MP3Info.sArtist)
SongName = Dir
fname = mp3path & SongName
i = i + 1
Wend
.Height = .Text1(.Text1.Count - 1).Top + 1600
.TAG = mp3path
MDIForm1.Caption = "You must close this form before continuing"
.Show
' .WindowState = 2
End With
TAG = "wait"
While TAG = "wait"
DoEvents
Wend
i = 1
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2
f1 = FreeFile
Open xmlpath & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
SongName = Dir(mp3path & "\*.mp3")
i = 1
While Not Len(SongName) = 0
' if you can return the name of the artist you put the code in here
mytag = GetMP3Tag(mp3path & SongName)
Artist = RTrim(MP3Info.sArtist)
If Len(Artist) = 0 Then Artist = "UNKOWN"
songpath = "<song path=""" & mp3Path2 & """ artist=""" & Artist & """ title=""" songname & """/> "
Print #f1, songpath
Print #f2, SongName
Sleep 100
SongName = Dir
Wend
Print #f1, "</songs>"
Close
End Sub
Feb 2nd, 2005, 11:50 PM
#20
Re: help please
songpath = "<song path=""" & mp3Path2 & """ artist=""" & Artist & """ title=""" & songname & """/> "
forgot an & !
Feb 2nd, 2005, 11:58 PM
#21
Thread Starter
Hyperactive Member
Re: help please
<?xml version="1.0"?>
<songs>
<song path="C:\Program Files\mgamerz\my_mp3s\07 Sweet Revenge.mp3" artist="michael kamen" title="07 Sweet Revenge.mp3"/>
</songs>
for some reason its writing the xml with the full path again wheras I need the xml to be llike this
<?xml version="1.0"?>
<songs>
<song path="my_mp3s\07 Sweet Revenge.mp3" artist="michael kamen" title="07 Sweet Revenge.mp3"/>
</songs>
Feb 3rd, 2005, 12:03 AM
#22
Re: help please
If you only want it to work with these two folders, i can fix it.
this will get you the folder that you want
VB Code:
right(mp3path,(len(mp3path)- len(xmlpath)+1))
you have two options. include this in the code, or create a variable and then use the variable.
I'd say DIM MyPath as string, and then MyPath = right(mp3path,(len(mp3path)- len(xmlpath)+1))
It returns this: my_mp3s\
Last edited by dglienna; Feb 3rd, 2005 at 12:09 AM .
Feb 3rd, 2005, 12:10 AM
#23
Thread Starter
Hyperactive Member
Re: help please
what it is for is a flash based mp3 player and when a track is added to the folder the xml updates. the xml file needs to be outside of the my_mp3 folder. so when the xml is updated all that needs to be uploaded is the xml file and the folder my_mp3s. Hop you get what I mean. thats why I need the xml to come out in this format:
<?xml version="1.0"?>
<songs>
<song path="my_mp3s/songname.mp3"artist="" title=""/>
</songs>
how I had it works apart from the path I get the full path
cheers
Feb 3rd, 2005, 12:49 AM
#24
Re: help please
VB Code:
dim MyPath as String
MyPath = right(mp3path,(len(mp3path)- len(xmlpath)+1))
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" songname & """/> "
Feb 3rd, 2005, 07:37 AM
#25
Thread Starter
Hyperactive Member
Re: help please
tried that but still havin no joy with the xml file it is continuing to write the full path indstead of just
<?xml version="1.0"?>
<songs>
<song path="my_mp3s/.mp3"artist="" title=""/>
</songs>
VB Code:
Private Sub Command2_Click()
Dim f1 As Integer, xmlpath As String, songpath As String, mp3path As String, f2 As Integer, i As Integer
Dim MyPath As String
Dim Artist As String, SongName As String, artname As String, fname As String, mp3Path2 As String
Dim mytag As Boolean
mp3path = "C:\Program Files\mgamerz\my_mp3s\"
xmlpath = "C:\program files\mgamerz\ "
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1))
mp3Path2 = "my_mp3s\"
SongName = Dir(mp3path & "\*.mp3")
fname = mp3path & SongName
With Form4
While Not Len(SongName) = 0
' Artist = GetMP3Tag(fname)
If Not i = 0 Then
Load .Label1(i): Load .Text1(i)
.Label1(i).Top = .Label1(i - 1).Top + 350
.Text1(i).Top = .Text1(i - 1).Top + 350
.Label1(i).Visible = True: .Text1(i).Visible = True
End If
.Label1(i) = SongName
mytag = GetMP3Tag(fname)
.Text1(i) = RTrim(MP3Info.sArtist)
SongName = Dir
fname = mp3path & SongName
i = i + 1
Wend
.Height = .Text1(.Text1.Count - 1).Top + 1600
.TAG = mp3path
MDIForm1.Caption = "You must close this form before continuing"
.Show
' .WindowState = 2
End With
TAG = "wait"
While TAG = "wait"
DoEvents
Wend
i = 1
f2 = FreeFile
Open mp3path & "mp3.txt" For Output As #f2
f1 = FreeFile
Open xmlpath & "audiolist.xml" For Output As #f1
Print #f1, "<?xml version=""1.0""?>"
Print #f1, "<songs>"
SongName = Dir(mp3path & "\*.mp3")
i = 1
While Not Len(SongName) = 0
' if you can return the name of the artist you put the code in here
mytag = GetMP3Tag(mp3path & SongName)
Artist = RTrim(MP3Info.sArtist)
If Len(Artist) = 0 Then Artist = "UNKOWN"
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
Print #f1, songpath
Print #f2, SongName
Sleep 100
SongName = Dir
Wend
Print #f1, "</songs>"
Close
End Sub
Feb 3rd, 2005, 07:53 AM
#26
Re: help please
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
Print #f1, songpath
Step through the program. I think that you must be doing something wrong. I don't see how it could be printing the path. MyPath is what I said that it was. Press FP on the line in question, and when it stops, hover over MyPath to see what it's value is. Are you running an old version?
Feb 3rd, 2005, 10:45 AM
#27
Thread Starter
Hyperactive Member
Re: help please
Right I think I'm starting to get there lol
I can now get this output
<?xml version="1.0"?>
<songs>
<song path="my_mp3s\" artist="Royksopp" title="02 - Poor Leno [jakatta Mix].mp3"/>
<song path="my_mp3s\" artist="Hayley Westenra" title="02-Never Say Goodbye.mp3"/>
<song path="my_mp3s\" artist="Michael Kamen" title="05 - Swamp.mp3"/>
<song path="my_mp3s\" artist="Michael Kamen" title="07 - Fire On Lake.mp3"/>
<song path="my_mp3s\" artist="Johnny Mathis" title="14 Johnny Mathis It's The Most Wonderful Time Of The Year.mp3"/>
</songs>
All I cannot get now is the mp3 after my mp3s - you know like this
<song path="my_mp3s\A song.mp3 " artist="Johnny Mathis" title="14 Johnny Mathis It's The Most Wonderful Time Of The Year.mp3"/>
</songs>
I have a feeling this is just something small that I am missing now - I appreciate you taking time to help me Thanks
Feb 3rd, 2005, 11:27 AM
#28
Re: help please
VB Code:
If Len(Artist) = 0 Then Artist = "UNKOWN"
MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath) + 1)) & " " & SongName
songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """/> "
get rid of the first MyPath statement, and compute it every time before the songpath statement. you said path, when you meant path and filename.
I hope that it is right now, unless the songname is not correct.
Feb 3rd, 2005, 12:19 PM
#29
Thread Starter
Hyperactive Member
Re: help please
Thanks very much David I think that has finally sorted it out. Waht its for is for a joint project working in conjunction with flash. I am waiting for the person who does the flash work to come home. If I have any small queries can I pm you.
Thanks very much again for spending your time helping me
Feb 3rd, 2005, 12:33 PM
#30
Re: help please
Sure. Happy to help
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width