Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. Subtle bug, VB style

Subtle bug, VB style

Scheduled Pinned Locked Moved Clever Code
helpcsharpdatabaselinq
7 Posts 6 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gregory Gadow
    wrote on last edited by
    #1

    I am writing a web-based message forum using the language I know best, Visual Basic. I have an xml file that maps the codes for inserting a smiley emoticon to the corresponding image file. This is what I wrote to initialize the object that holds this data:

    pSmileyList = New SortedDictionary(Of String, String)

    Dim Smileys As XDocument = XDocument.Load(Constants.SmileyImages + "index.xml")
    Dim Code As String = ""
    Dim Image As String = ""

    For Each S As XElement In Smileys...<Smiley>
    Code = S.@code
    Image = S.@image
    pSmileyList.Add(Code, Image)
    Next

    But the darn thing would not work: when it hit the For Each block, it jumped out and pSmileyList never got loaded. After nearly an hour of metaphorically banging my head against the wall, I figured out the problem and nearly banged my head against the wall for real. Visual Basic is not case sensitive. XML is. I am used to case not mattering. In VB, there is no difference at all between Smiley and smiley. In XML -- and therefore, in LINQ -- there is a difference. Yup: it took me an hour to realize that was using <smiley> in the XML file, and that the problem could be fixed by using Smileys...<smiley> in my initialization. :doh: Edited for spelling.

    S B 2 Replies Last reply
    0
    • G Gregory Gadow

      I am writing a web-based message forum using the language I know best, Visual Basic. I have an xml file that maps the codes for inserting a smiley emoticon to the corresponding image file. This is what I wrote to initialize the object that holds this data:

      pSmileyList = New SortedDictionary(Of String, String)

      Dim Smileys As XDocument = XDocument.Load(Constants.SmileyImages + "index.xml")
      Dim Code As String = ""
      Dim Image As String = ""

      For Each S As XElement In Smileys...<Smiley>
      Code = S.@code
      Image = S.@image
      pSmileyList.Add(Code, Image)
      Next

      But the darn thing would not work: when it hit the For Each block, it jumped out and pSmileyList never got loaded. After nearly an hour of metaphorically banging my head against the wall, I figured out the problem and nearly banged my head against the wall for real. Visual Basic is not case sensitive. XML is. I am used to case not mattering. In VB, there is no difference at all between Smiley and smiley. In XML -- and therefore, in LINQ -- there is a difference. Yup: it took me an hour to realize that was using <smiley> in the XML file, and that the problem could be fixed by using Smileys...<smiley> in my initialization. :doh: Edited for spelling.

      S Offline
      S Offline
      Stryder_1
      wrote on last edited by
      #2

      Guess that will teach you for using VB....and XML.... ;P Let the flames begin :-D

      I P 2 Replies Last reply
      0
      • S Stryder_1

        Guess that will teach you for using VB....and XML.... ;P Let the flames begin :-D

        I Offline
        I Offline
        Ian Shlasko
        wrote on last edited by
        #3

        At least he's not using VB6 and INI files, right?

        Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

        1 Reply Last reply
        0
        • S Stryder_1

          Guess that will teach you for using VB....and XML.... ;P Let the flames begin :-D

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          :flame: XML is awesome! Unless you abuse it, I guess.

          M 1 Reply Last reply
          0
          • G Gregory Gadow

            I am writing a web-based message forum using the language I know best, Visual Basic. I have an xml file that maps the codes for inserting a smiley emoticon to the corresponding image file. This is what I wrote to initialize the object that holds this data:

            pSmileyList = New SortedDictionary(Of String, String)

            Dim Smileys As XDocument = XDocument.Load(Constants.SmileyImages + "index.xml")
            Dim Code As String = ""
            Dim Image As String = ""

            For Each S As XElement In Smileys...<Smiley>
            Code = S.@code
            Image = S.@image
            pSmileyList.Add(Code, Image)
            Next

            But the darn thing would not work: when it hit the For Each block, it jumped out and pSmileyList never got loaded. After nearly an hour of metaphorically banging my head against the wall, I figured out the problem and nearly banged my head against the wall for real. Visual Basic is not case sensitive. XML is. I am used to case not mattering. In VB, there is no difference at all between Smiley and smiley. In XML -- and therefore, in LINQ -- there is a difference. Yup: it took me an hour to realize that was using <smiley> in the XML file, and that the problem could be fixed by using Smileys...<smiley> in my initialization. :doh: Edited for spelling.

            B Offline
            B Offline
            BillHudson
            wrote on last edited by
            #5

            I know just what you mean. I'm playing around in Ubuntu and it's command line is case sensitive as well as the directory structure and filenames. I don't know how many times I think to myself "I know that file should be there!" only to realize that it's the case. I like to name files with CapsForEachWord so that it's easy to read but I like to just type in lower case to access for convenience. It's hard to change a habit If your anything like me you'll have that problem again unless you do allot of VB/XML

            1 Reply Last reply
            0
            • P PIEBALDconsult

              :flame: XML is awesome! Unless you abuse it, I guess.

              M Offline
              M Offline
              Michael Eber
              wrote on last edited by
              #6

              Oh yeh. Xml is AWESOME. But VB.NET used on Xml is what sucks. ;) OK Stryder, I deflected the flames to myself.

              P 1 Reply Last reply
              0
              • M Michael Eber

                Oh yeh. Xml is AWESOME. But VB.NET used on Xml is what sucks. ;) OK Stryder, I deflected the flames to myself.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                Michael Eber wrote:

                But VB.NET used on Xml is what sucks

                I'm not sure XML enters into it. :~

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups