3 Replies - 3029 Views - Last Post: 17 October 2011 - 07:11 AM

Poll: + or & (7 member(s) have cast votes)

Your choice

  1. + (1 votes [14.29%])

    Percentage of vote: 14.29%

  2. & (5 votes [71.43%])

    Percentage of vote: 71.43%

  3. Both (1 votes [14.29%])

    Percentage of vote: 14.29%

Vote Guests cannot vote

#1 Yo!  Icon User is offline

  • D.I.C Head


Reputation: 4
  • View blog
  • Posts: 83
  • Joined: 03-September 11

+ or &

Posted 14 October 2011 - 10:21 PM

Hi everyone,
I was wondering what you use: + or & for your code
messagebox.show("Eat carrots "+ corn.tostring)

or
messagebox.show("Eat carrots "& corn.tostring)


I don't notice much of a difference other than it's easier to type + than &
Is This A Good Question/Topic? 0
  • +

Replies To: + or &

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: + or &

Posted 14 October 2011 - 11:28 PM

I use both but in different situation:
+ in addition
& Concatenating string

Which one is easy to type has nothing to do with programming.... just follow the syntax and you will be fine.

Also I dont see the reason of Poll for this and it should be in VB.NET Programmer forum
Was This Post Helpful? 1
  • +
  • -

#3 dbasnett  Icon User is offline

  • D.I.C Addict

Reputation: 102
  • View blog
  • Posts: 584
  • Joined: 01-October 08

Re: + or &

Posted 15 October 2011 - 05:42 AM

Agreeing with smohd, + for addition, & for concatenation.
Was This Post Helpful? 0
  • +
  • -

#4 Tryparse  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 80
  • View blog
  • Posts: 193
  • Joined: 20-April 10

Re: + or &

Posted 17 October 2011 - 07:11 AM

Best practice is to use & for string concatenation in VB. There's a good discussion of it on Stackoverflow.

And the ampersand is actually easier for me to type, because my pinkys are slightly retarded. I hate writing sql because of all the underscores ... the + is even farther away ...
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1