[RESOLVED] [2005] Losing values
Okay im making a class for my MP3 to read ID3 Tags,
VB Code:
Public Class MP3
Private Structure ID3
Dim SONGNAME As String
Dim ALBUM As String
Dim ARTIST As String
Dim YEAR As String
Dim COMMENT As String
Dim GENRE As String
End Structure
Dim _FILENAME As String
Private mID3 As ID3
Public Sub New(ByVal fileName As String)
_FILENAME = fileName
readFile()
End Sub
Private Sub readFile()
Dim fs As New IO.FileStream(_FILENAME, IO.FileMode.Open, IO.FileAccess.Read)
Dim br As New IO.BinaryReader(fs)
br.BaseStream.Seek(-128, IO.SeekOrigin.End)
If br.ReadChars(3) = "TAG" Then
With mID3
.SONGNAME = br.ReadChars(30)
.ARTIST = br.ReadChars(30)
.ALBUM = br.ReadChars(30)
.YEAR = br.ReadChars(4)
.COMMENT = br.ReadChars(30)
.GENRE = br.ReadChars(1)
End With
Else
fs.Close()
br.Close()
End If
End Sub
Public Function getSongName() As String
Return mID3.SONGNAME
End Function
Public Function getAlbum() As String
Return mID3.ALBUM
End Function
Public Function getArtist() As String
Return mID3.ARTIST
End Function
Public Function getYear() As String
Return mID3.YEAR
End Function
Public Function getComment() As String
Return mID3.COMMENT
End Function
Public Function getGenre() As String
Return mID3.GENRE
End Function
End Class
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myMP3 As New MP3("C:\Documents and Settings\Jason\My Documents\My Music\iTunes\iTunes Music\Trapt\Unknown Album\01 Headstrong.mp3")
With myMP3
Debug.Print(.getAlbum)
Debug.Print(.getArtist)
Debug.Print(.getComment)
Debug.Print(.getSongName)
Debug.Print(.getYear)
Debug.Print(.getGenre)
End With
End Sub
It all works great, the values get filled. But as soon as I try and acess the values through .getArtist etc the mID3.ARTIST becomes Null..Why is the value being reset?