Bug or problem?

Dim song As String = tags.artist & " - " & tags.song

When setting a text box to song it only appears with the tags.artist. When debugging i have found that first of all it sets the song to "tags.artist but it misses out the ending ". Is this a bug with vb and if so can it be fixed or is it something i have done wrong



Answer this question

Bug or problem?

  • dfrenchie720

    Hi ReneeC,

    Thanks for that, it seems to of work now. Its a bit of pain having to do it that way but i guess it will do for now. If its a problem with me then it might have something to do with my ID3 class so i'll get looking into that.

    P.S. Your the first ever person to get my name correct first time. When other people type it they always type "gamesplanet" for some reason.

  • xrvjorn

    Hi gamesplant!!

    The behavior you reported would the behavior you describe from your syntax.

    I believe the concatenation is sequential and in this case, it's going to clear songs with the contents of tags.... I think pershaps in this case you may need to store the old contents of songs in a temporary string and then concatenate tags and the temporary string into the texbox.



  • jb_tiburon

    Hi Renee

    I'm sure you don't, not being a C programmer, but it's worth having a look at how ID3 tags are written.

    In spec V1, which is the only version he reads the Artist information contains 30 bytes. If the name of the artist does not contain 30 bytes then the remaining ones should be filled up with binary 0's.

    It would therefore be quite easy for a program trying to read the tag to finish with a string terminated in a null.

    BTW - I still don't understand what you wrote above :-)

    Dave


  • Tillmann #Europe#

    Gamesplant

    In response to your request for code - it doesn't need much at all.

    Define a structure to hold the information (or you could use a class)

    Public Structure ID3Tag
    <VBFixedString(3)> Public Header As String
    <VBFixedString(30)> Public SongTitle As String
    <VBFixedString(30)> Public Artist As String
    <VBFixedString(30)> Public Album As String
    <VBFixedString(4)> Public Year As String
    <VBFixedString(30)> Public Comment As String
    <VBFixedString(1)> Public Genre As Byte
    End Structure

    Open the file you want to read and extract the information

    Dim Tag As New ID3Tag
    Dim sSongTitle As String

    FileOpen(1, "your_file_name", OpenMode.Binary)
    FileGet(1, Tag, LOF(1) - 127)
    FileClose(1)

    Then strip off the nulls from the end

    sSongTitle = Microsoft.VisualBasic.Left(Tag.SongTitle, InStr(Tag.SongTitle, Chr(0)) - 1)

    Obviously you need lots more to make it robust but that's the bare bones.

    Dave


  • ChRiZ

    No i don't get any error messages. The reason i'm doing this is because im making an mp3 player and i want to display Artist - Song in a listbox. I have tried using a varible and i have also tried listbox.items.add(tags.artist & " - " & tags.song) but all that appears is the Artist and no error message occurs. Is it more likely to be a problem with Visual Basic or the .NET Framework

  • Calua

    Probably not what you want to hear but it works fine on my machine whether tags is a class or a structure.

    Do you not get any error messages


  • SanjayNarang

    I'd like to state the obvious...to ensure that tag.song has a value. The syntax looks fine.

    :)

    Adamus Turner



  • caramela

    I would check that the tags.artist does not have a NULL character at the end.

    This is about the only way the textbox display would be truncated in the way you describe.


  • Lukas Torstensson

    ReneeC wrote:

    The behavior you reported would the behavior you describe from your syntax.

    I believe the concatenation is sequential and in this case, it's going to clear songs with the contents of tags.... I think pershaps in this case you may need to store the old contents of songs in a temporary string and then concatenate tags and the temporary string into the texbox.

    I hope that means more to you than it does to me.


  • mohamed makin

    I've seen this behavior before Dave and i had the same increduality that gamesplant has expressed. I can't remember if it was in DOT NET or VB6 but I have seen it. I also know I'm not at in the habit of terminating things with nulls. I am very sure that wasn't the problem.



  • GreatC

    Yes i am sure that tag.song has a value. Even if it didn't i would still expect to see the dash after the artist.

    After debugging some more i have found that its the tags.artist and tags.song that contain the values without the ending ". I'm guessing its to do with my ID3 class because its only able to read ID3 V1.0. Is it possible for someone to give me a link to a tutorial for reading these ID3 tags or could you post up some example code please

    Thanks In Advanced,
    Gamesplant

  • Bug or problem?