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. The Weird and The Wonderful
  4. Why oh why???

Why oh why???

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
9 Posts 6 Posters 0 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.
  • E Offline
    E Offline
    emartinho
    wrote on last edited by
    #1

    Found this bit of VB/VBA code to be interesting! :D If (Len(Replace(colourStyle, AP_colourStyle, "")) = 0) then For some reason it took me a little while to realize that it simply meant: if (Trim$(colourStyle) = Trim$(AP_colourStyle)) then :-O I could probably leave out the trim$() calls, but I like to make sure there are no pesky extra surronding spaces. -EM

    R L P 3 Replies Last reply
    0
    • E emartinho

      Found this bit of VB/VBA code to be interesting! :D If (Len(Replace(colourStyle, AP_colourStyle, "")) = 0) then For some reason it took me a little while to realize that it simply meant: if (Trim$(colourStyle) = Trim$(AP_colourStyle)) then :-O I could probably leave out the trim$() calls, but I like to make sure there are no pesky extra surronding spaces. -EM

      R Offline
      R Offline
      RobCroll
      wrote on last edited by
      #2

      Not quite the same. What if colourStyle already has a length of 0.

      "You get that on the big jobs."

      M E 2 Replies Last reply
      0
      • E emartinho

        Found this bit of VB/VBA code to be interesting! :D If (Len(Replace(colourStyle, AP_colourStyle, "")) = 0) then For some reason it took me a little while to realize that it simply meant: if (Trim$(colourStyle) = Trim$(AP_colourStyle)) then :-O I could probably leave out the trim$() calls, but I like to make sure there are no pesky extra surronding spaces. -EM

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Incorrect. Replace() replaces every instance, so with

        colourStyle="APAPAP"
        AP_colourStyle="AP"

        the string would vanish and fire the original if, and not yours. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        M E 2 Replies Last reply
        0
        • R RobCroll

          Not quite the same. What if colourStyle already has a length of 0.

          "You get that on the big jobs."

          M Offline
          M Offline
          Marc A Brown
          wrote on last edited by
          #4

          Good catch.

          1 Reply Last reply
          0
          • L Luc Pattyn

            Incorrect. Replace() replaces every instance, so with

            colourStyle="APAPAP"
            AP_colourStyle="AP"

            the string would vanish and fire the original if, and not yours. :)

            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            M Offline
            M Offline
            Marc A Brown
            wrote on last edited by
            #5

            Good point.

            1 Reply Last reply
            0
            • L Luc Pattyn

              Incorrect. Replace() replaces every instance, so with

              colourStyle="APAPAP"
              AP_colourStyle="AP"

              the string would vanish and fire the original if, and not yours. :)

              Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              E Offline
              E Offline
              emartinho
              wrote on last edited by
              #6

              That's a great point and here's my 5. These vars could never have that type of situation due to how they get their data, but the basic premise you point out is correct. Assuming that the 2 vars refer to the same type of data (i.e. a "ColourStyle"), but from 2 different sources, I still don't see why someone would create that line of code. What design instructions would lead someone to use that type of logic? Any ideas, I'm interested to see other's take on this. -EM

              B 1 Reply Last reply
              0
              • R RobCroll

                Not quite the same. What if colourStyle already has a length of 0.

                "You get that on the big jobs."

                E Offline
                E Offline
                emartinho
                wrote on last edited by
                #7

                Best catch of the 2 so far! Here's my 5. I hadn't noticed that particular morsel, and it is a possibility given the usage of these vars elsewhere in the code, and how the values get attributed to them. Again fine catch. Kudos! Hmm, does anyone really say "Kudos" anymore??????? :-O -EM

                1 Reply Last reply
                0
                • E emartinho

                  That's a great point and here's my 5. These vars could never have that type of situation due to how they get their data, but the basic premise you point out is correct. Assuming that the 2 vars refer to the same type of data (i.e. a "ColourStyle"), but from 2 different sources, I still don't see why someone would create that line of code. What design instructions would lead someone to use that type of logic? Any ideas, I'm interested to see other's take on this. -EM

                  B Offline
                  B Offline
                  Blake Miller
                  wrote on last edited by
                  #8

                  emartinho wrote:

                  These vars could never have that type of situation due to how they get their data

                  But in cases where your development and coding is outsourced (and maybe even internal), this is a bad premise in itself, since they will cut and paste so MUCH of your existing code base, the error these two variables 'will never encounter' will show up everywhere else in your code.

                  1 Reply Last reply
                  0
                  • E emartinho

                    Found this bit of VB/VBA code to be interesting! :D If (Len(Replace(colourStyle, AP_colourStyle, "")) = 0) then For some reason it took me a little while to realize that it simply meant: if (Trim$(colourStyle) = Trim$(AP_colourStyle)) then :-O I could probably leave out the trim$() calls, but I like to make sure there are no pesky extra surronding spaces. -EM

                    P Offline
                    P Offline
                    Pong D Panda
                    wrote on last edited by
                    #9

                    Both code goes to the category of Hall of Shame? :wtf:

                    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