C0D3 MA5T3R Homepage

ID3 Tag Reader

Reads the ID3 tags from MP3 Audio files and return their values

(See Below Code)

'
'Prepare the variables for holding the tag information
Dim HTag As Boolean
'Set the tag holding strings to the right length to get the right file info.
Dim Tagged As String * 3
Dim Title As String * 30
Dim Artist As String * 30
Dim Album As String * 30
Dim Dated As String * 4
Dim Comment As String * 30

'Call this function to check a tag
Private Sub GetTag(File)
'
'Prepare TagFile to act as our file handler
Dim TagFile As Integer
TagFile = FreeFile

'Open the file
Open File For Binary As #TagFile
'Check to see if it has a tag - i.e. Tagged will equal "TAG"
Get #TagFile, FileLen(File) - 127, Tagged
If Tagged = "TAG" Then GoTo has Else GoTo hasnt 'go to the appropriate section

has:
'Set HTag to show a Tag exists
HTag = True
'Set the other values to show the Title, Artist, Album, Date and Comment of the track - Get the info. from the openned file
Get #TagFile, , Title
Get #TagFile, , Artist
Get #TagFile, , Album
Get #TagFile, , Dated
Get #TagFile, , Comment
'Finished getting info
GoTo done

hasnt:
'Set HTag to show a Tag does not exist
HTag = False
'Set values to null to show no tag was found
Title = ""
Artist = ""
Album = ""
Dated = ""
Comment = ""
'Finished
GoTo done

done:
'Close the openned file
Close #TagFile
End Sub

'Example of how to call the function
Private Sub Command1_Click()
GetTag (Text1.Text) 'Where Text1 contains the filename that is to be checked
'The values HTag, Title, Artist, Album, Dated and Comment will then contain tag information
End Sub

(Copy and Paste this code into your Visual Basic project)

*Want to join the C0D3 MA5T3R e-mail list?*

Get all the latest code news and articles, and even submit your own.

You can sign-up for free below (you may opt-out at any time):

Join the mailing list
Enter your name and email address:
Name:
Email:  
Subscribe      Unsubscribe