Difference between + and & in concatenation

Results 1 to 3 of 3

Thread: Difference between + and & in concatenation

  1. #1
    Kentium Guest

    Default Difference between + and & in concatenation

    My coworker used the + (plus) sign to concatenate two strings, and I&#039;ve always used the apersand (&).<BR><BR>Both seem to work, but it&#039;s my understanding that + is strictly used to add numeric values.<BR><BR>Can someone explain why + works for concatenation?<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default + *ONLY* guaranteed to work if...

    ...the two things being concatenated are *already* BOTH strings!<BR><BR>It makes sense: What could "abc"+"def" mean *except* concatenation?<BR><BR>But it&#039;s truly stupid to use + for string concatenation, because one of these days you&#039;ll slip up and use it in the wrong place and then get a TYPE MISMATCH error or some very confusing output or or or. <BR><BR>So I *VERY FIRMLY* say:<BR><BR>ALWAYS USE ONLY & FOR STRING CONCATENATION in VBScript.<BR><BR>

  3. #3
    Kentium Guest

    Default RE: + *ONLY* guaranteed to work if...

    Thanks! Great explanation.

Posting Permissions

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