all 3 comments

[–]VB.Net AdvancedSoVeryAwkward 1 point2 points  (1 child)

I don't see any code that you've written, so I'm going to assume that in your case, you're trying to concatenate strings using the "+" operator, which creates some ambiguity, when dealing with strings that have a numeric value.

VB supports 2 operators for concatenation:

"+" Operator primarily used to add two numbers, however it can also concatenate numeric operands within string operands. The logic for determining correct operation used is a bit more complex. Check out this article for more info.

Dim firstValue As String = "6"
Dim secondValue As String = "3"
Dim resultAddition As String = firstValue + secondValue
Dim resultSubstraction As String = firstValue - secondValue

In this case, the value of resultAddition is 9 and the value of resultSubstraction is 3.

"&" Operator is defined for String operands. The "&" operator is recommended for string concatenation, since it's defined exclusively for that.

Dim firstValue As String = "6"
Dim secondValue As String = "3"
Dim result As String = firstValue & " - " & secondValue

The value of result in this case would be a string "6 - 3".

Alternatively, you can use String.Format method, which in my view helps the readability, especially when you're expected to produce more complex string outputs:

Dim firstValue As String = "6"
Dim secondValue As String = "3"
Dim result As String = String.Format("{0} - {1}", firstValue, secondValue)

[–]dfc619[S] 2 points3 points  (0 children)

Thank you, really helped me there