Results 1 to 13 of 13

Thread: [RESOLVED] [2005] Losing values

Threaded View

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Resolved [RESOLVED] [2005] Losing values

    Okay im making a class for my MP3 to read ID3 Tags,

    VB Code:
    1. Public Class MP3
    2.     Private Structure ID3
    3.         Dim SONGNAME As String
    4.         Dim ALBUM As String
    5.         Dim ARTIST As String
    6.         Dim YEAR As String
    7.         Dim COMMENT As String
    8.         Dim GENRE As String
    9.     End Structure
    10.     Dim _FILENAME As String
    11.  
    12.     Private mID3 As ID3
    13.     Public Sub New(ByVal fileName As String)
    14.         _FILENAME = fileName
    15.         readFile()
    16.     End Sub
    17.  
    18.     Private Sub readFile()
    19.         Dim fs As New IO.FileStream(_FILENAME, IO.FileMode.Open, IO.FileAccess.Read)
    20.         Dim br As New IO.BinaryReader(fs)
    21.         br.BaseStream.Seek(-128, IO.SeekOrigin.End)
    22.         If br.ReadChars(3) = "TAG" Then
    23.             With mID3
    24.                 .SONGNAME = br.ReadChars(30)
    25.                 .ARTIST = br.ReadChars(30)
    26.                 .ALBUM = br.ReadChars(30)
    27.                 .YEAR = br.ReadChars(4)
    28.                 .COMMENT = br.ReadChars(30)
    29.                 .GENRE = br.ReadChars(1)
    30.             End With
    31.         Else
    32.             fs.Close()
    33.             br.Close()
    34.         End If
    35.     End Sub
    36.  
    37.     Public Function getSongName() As String
    38.         Return mID3.SONGNAME
    39.     End Function
    40.  
    41.     Public Function getAlbum() As String
    42.         Return mID3.ALBUM
    43.     End Function
    44.  
    45.     Public Function getArtist() As String
    46.         Return mID3.ARTIST
    47.     End Function
    48.  
    49.     Public Function getYear() As String
    50.         Return mID3.YEAR
    51.     End Function
    52.  
    53.     Public Function getComment() As String
    54.         Return mID3.COMMENT
    55.     End Function
    56.  
    57.     Public Function getGenre() As String
    58.         Return mID3.GENRE
    59.     End Function
    60.  
    61. End Class
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim myMP3 As New MP3("C:\Documents and Settings\Jason\My Documents\My Music\iTunes\iTunes Music\Trapt\Unknown Album\01 Headstrong.mp3")
    3.         With myMP3
    4.             Debug.Print(.getAlbum)
    5.             Debug.Print(.getArtist)
    6.             Debug.Print(.getComment)
    7.             Debug.Print(.getSongName)
    8.             Debug.Print(.getYear)
    9.             Debug.Print(.getGenre)
    10.         End With
    11.     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?
    Last edited by |2eM!x; Nov 30th, 2006 at 09:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width