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. String stuff

String stuff

Scheduled Pinned Locked Moved Clever Code
help
15 Posts 10 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.
  • S Offline
    S Offline
    sbeckstead
    wrote on last edited by
    #1

    In vb the '&' concatenates strings"

    OutLine = OutLine = "," & "D," & ThisDataset.Tables("TimeSheet").Rows(i).Item("Double Time").ToString()

    I would expect outline to be added to but all I was getting was "False" After staring at it for quite a while I realized what the problem was. It's subtle but not incredibly difficult once you realize what the "False" means.

    C R S T D 5 Replies Last reply
    0
    • S sbeckstead

      In vb the '&' concatenates strings"

      OutLine = OutLine = "," & "D," & ThisDataset.Tables("TimeSheet").Rows(i).Item("Double Time").ToString()

      I would expect outline to be added to but all I was getting was "False" After staring at it for quite a while I realized what the problem was. It's subtle but not incredibly difficult once you realize what the "False" means.

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      You lost me after the vb part. ;P

      Chris Meech I am Canadian. [heard in a local bar] Nobody likes jerks. [espeir] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

      1 Reply Last reply
      0
      • S sbeckstead

        In vb the '&' concatenates strings"

        OutLine = OutLine = "," & "D," & ThisDataset.Tables("TimeSheet").Rows(i).Item("Double Time").ToString()

        I would expect outline to be added to but all I was getting was "False" After staring at it for quite a while I realized what the problem was. It's subtle but not incredibly difficult once you realize what the "False" means.

        S Offline
        S Offline
        Shog9 0
        wrote on last edited by
        #3

        Ah, the dangers of context-sensitive operators...

        every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

        1 Reply Last reply
        0
        • S sbeckstead

          In vb the '&' concatenates strings"

          OutLine = OutLine = "," & "D," & ThisDataset.Tables("TimeSheet").Rows(i).Item("Double Time").ToString()

          I would expect outline to be added to but all I was getting was "False" After staring at it for quite a while I realized what the problem was. It's subtle but not incredibly difficult once you realize what the "False" means.

          R Offline
          R Offline
          Rob Graham
          wrote on last edited by
          #4

          Another reason to hate vb: oberloading = instead of using ==

          P 1 Reply Last reply
          0
          • S sbeckstead

            In vb the '&' concatenates strings"

            OutLine = OutLine = "," & "D," & ThisDataset.Tables("TimeSheet").Rows(i).Item("Double Time").ToString()

            I would expect outline to be added to but all I was getting was "False" After staring at it for quite a while I realized what the problem was. It's subtle but not incredibly difficult once you realize what the "False" means.

            T Offline
            T Offline
            Tim Carmichael
            wrote on last edited by
            #5

            And how is this a bug? I read it as a boolean expression: Is the left side of the equation (Outline) equal to the right side of the equation? If the answer is no, the result is false... It may be an issue with not understanding the language syntax, but, should others, unfamiliar with C, C++, C#, etc. post such nuances as bugs? Just my thoughts... Tim

            S 1 Reply Last reply
            0
            • T Tim Carmichael

              And how is this a bug? I read it as a boolean expression: Is the left side of the equation (Outline) equal to the right side of the equation? If the answer is no, the result is false... It may be an issue with not understanding the language syntax, but, should others, unfamiliar with C, C++, C#, etc. post such nuances as bugs? Just my thoughts... Tim

              S Offline
              S Offline
              sbeckstead
              wrote on last edited by
              #6

              This is a classic subtle bug. A piece of code that is perfectly syntacticaly correct but has unintended results. What exactly do YOU define as a bug? Since I didn't write it as a boolean expression the subtle typo that caused it to become a boolean expression formed the basis for it being considered a bug. It's not a misunderstanding of the syntax, and actually has little to do with the language itself. I think you failed to study the entire expression. In C for example a similar bug might be created with the expression

              thivar = thivar = 1; (instead of: thisvar = thisvar + 1;)

              or more likely: if (thisvar = thatvar-5) { //do something meaningfull and elegant here } The length of the expression and the complexity of the line of code makes it more subtle than that trivial expression. I've been at this for more than 30 years, It's these stupid subtle typos that still cause the most unintended results. :laugh:

              T P 2 Replies Last reply
              0
              • S sbeckstead

                This is a classic subtle bug. A piece of code that is perfectly syntacticaly correct but has unintended results. What exactly do YOU define as a bug? Since I didn't write it as a boolean expression the subtle typo that caused it to become a boolean expression formed the basis for it being considered a bug. It's not a misunderstanding of the syntax, and actually has little to do with the language itself. I think you failed to study the entire expression. In C for example a similar bug might be created with the expression

                thivar = thivar = 1; (instead of: thisvar = thisvar + 1;)

                or more likely: if (thisvar = thatvar-5) { //do something meaningfull and elegant here } The length of the expression and the complexity of the line of code makes it more subtle than that trivial expression. I've been at this for more than 30 years, It's these stupid subtle typos that still cause the most unintended results. :laugh:

                T Offline
                T Offline
                Tim Carmichael
                wrote on last edited by
                #7

                Actually, I DID understand the syntax, both from a VB and from a C reference. The results may have been unintentional, but the code worked as it should. I took the 'bug' reference to mean there was a problem with the language parser, meaning, the code is not working as written. So, in that context, the bug is with HOW the code was written, not with the language itself... As yes, after doing this for over 25 years, it IS those subtle typos that cause the most problems.

                S M 2 Replies Last reply
                0
                • T Tim Carmichael

                  Actually, I DID understand the syntax, both from a VB and from a C reference. The results may have been unintentional, but the code worked as it should. I took the 'bug' reference to mean there was a problem with the language parser, meaning, the code is not working as written. So, in that context, the bug is with HOW the code was written, not with the language itself... As yes, after doing this for over 25 years, it IS those subtle typos that cause the most problems.

                  S Offline
                  S Offline
                  sbeckstead
                  wrote on last edited by
                  #8

                  True but a (at least my definition) bug is any unintended functioning of the program whether the compiler, or programmer is causing the unintended result is irrelevant. If you want a compiler bug I'll post the one that got me in trouble with Microsoft. It's with their old version 6 C compiler (yes C compiler not visual C) and was released about the time that the C standard was being ratified. Scott

                  1 Reply Last reply
                  0
                  • T Tim Carmichael

                    Actually, I DID understand the syntax, both from a VB and from a C reference. The results may have been unintentional, but the code worked as it should. I took the 'bug' reference to mean there was a problem with the language parser, meaning, the code is not working as written. So, in that context, the bug is with HOW the code was written, not with the language itself... As yes, after doing this for over 25 years, it IS those subtle typos that cause the most problems.

                    M Offline
                    M Offline
                    moon_stick
                    wrote on last edited by
                    #9

                    All my code works as it's written. Sometimes I just didn't mean to write it that way...!! ;-) Dave

                    1 Reply Last reply
                    0
                    • S sbeckstead

                      In vb the '&' concatenates strings"

                      OutLine = OutLine = "," & "D," & ThisDataset.Tables("TimeSheet").Rows(i).Item("Double Time").ToString()

                      I would expect outline to be added to but all I was getting was "False" After staring at it for quite a while I realized what the problem was. It's subtle but not incredibly difficult once you realize what the "False" means.

                      D Offline
                      D Offline
                      Daniel Turini
                      wrote on last edited by
                      #10

                      And Option Explicit On on all files... 'nuf said.

                      L 1 Reply Last reply
                      0
                      • D Daniel Turini

                        And Option Explicit On on all files... 'nuf said.

                        L Offline
                        L Offline
                        LittleGreenMartian
                        wrote on last edited by
                        #11

                        True, but why should there be another state apart from Option Explicit? As long as we cater for fools, could we end up looking like the sheep we are sheparding? :doh:

                        1 Reply Last reply
                        0
                        • R Rob Graham

                          Another reason to hate vb: oberloading = instead of using ==

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

                          I still say that the C (and its ilk) assignment operator should be :=, as in Pascal.

                          G 1 Reply Last reply
                          0
                          • S sbeckstead

                            This is a classic subtle bug. A piece of code that is perfectly syntacticaly correct but has unintended results. What exactly do YOU define as a bug? Since I didn't write it as a boolean expression the subtle typo that caused it to become a boolean expression formed the basis for it being considered a bug. It's not a misunderstanding of the syntax, and actually has little to do with the language itself. I think you failed to study the entire expression. In C for example a similar bug might be created with the expression

                            thivar = thivar = 1; (instead of: thisvar = thisvar + 1;)

                            or more likely: if (thisvar = thatvar-5) { //do something meaningfull and elegant here } The length of the expression and the complexity of the line of code makes it more subtle than that trivial expression. I've been at this for more than 30 years, It's these stupid subtle typos that still cause the most unintended results. :laugh:

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

                            A "logic error".

                            1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              I still say that the C (and its ilk) assignment operator should be :=, as in Pascal.

                              G Offline
                              G Offline
                              Gary Wheeler
                              wrote on last edited by
                              #14

                              I always thought that was stupid. Which operation do you perform more often in your code, assignment or test for equality? Assignment, of course. Making the assignment operation require two characters and the test for equality one character is inefficient. At that, at least on U.S. keyboards, it's even worse. The ":=" construct requires four keypress actions: press Shift, press :, release Shift, press =.


                              Software Zen: delete this;

                              P 1 Reply Last reply
                              0
                              • G Gary Wheeler

                                I always thought that was stupid. Which operation do you perform more often in your code, assignment or test for equality? Assignment, of course. Making the assignment operation require two characters and the test for equality one character is inefficient. At that, at least on U.S. keyboards, it's even worse. The ":=" construct requires four keypress actions: press Shift, press :, release Shift, press =.


                                Software Zen: delete this;

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

                                No, I meant a bare = is not a part of the syntax; == is test for equality and := is assignment. I'll gladly type the extra character (two keystrokes) to save myself from unexpected functionality.

                                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