473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Be nice

It may help if someone at Microsoft knows how to write VBScript. Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #1
24 2215
Thanks George, I've forwarded the issue along to some folks (when I reviewed
the article, I found 6 or 7 other things I didn't like).

"George Hester" <he********@hotmail.com> wrote in message
news:#L**************@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when
was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #2
George Hester wrote on 02 nov 2003 in
microsoft.public.inetserver.asp.general:
It may help if someone at Microsoft knows how to write VBScript.
Since when was "+" a string concatenation character in VBScript?


"+" always was a string concatenation operator in VBScript
and in most earlier Basixc dialects.

The "&" as an more specific alternative is a latecomer in Basic.

Stopping the "+" operator having this behavour and reserving it for
numerical adding and optional unary operator behavour, would be a good
thing, IMHO.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3
George Hester wrote:
It may help if someone at Microsoft knows how to write VBScript.
Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

http://msdn.microsoft.com/library/en...catenation.asp

+ is both a concatenation and an addition operator. The only difference in
vbscript between + and & is that & will force concatenation. If both
operands can be coerced to numbers, addition will occur. If either operand
cannot be coerced to numeric, concatenation will occur. When & is used,
concatenation is the only operation allowed, which means that both operands
are coerced to strings before the operation is done. This is
well-documented.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
> + is both a concatenation and an addition operator. The only difference in
vbscript between + and & is that & will force concatenation. If both
operands can be coerced to numbers, addition will occur. If either operand
cannot be coerced to numeric, concatenation will occur. When & is used,
concatenation is the only operation allowed, which means that both operands are coerced to strings before the operation is done. This is
well-documented.


I don't think George is trying to state that this isn't well-documented. I
think he is just implying (and I tend to agree) that the default
recommendation for string operations be + ... I think they should be using &
in all cases where they are not intending to perform an addition operation
(and I think it's poor that this dual construct was ever there in the first
place). Just because you *can* do something, and that it *is* well
documented, doesn't mean it's the way you *should* do it...

Now, of course, you could argue from the other side, e.g. that the +
operator has multiple functions in other languages, such as T-SQL, JScript,
C#, etc. But when an alternative that is better defined is there, why not
use it instead?
Jul 19 '05 #5
Aaron Bertrand [MVP] wrote:
I don't think George is trying to state that this isn't
well-documented. I think he is just implying (and I tend to agree)
that the default recommendation for string operations be +


:-)
No, that is your interpretation of what George was saying. I think "It may
help if someone at Microsoft knows how to write VBScript." is a pretty clear
statement. And a very incorrect statement in this case. :-)

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6
Apparently since version 1 of VBScript according to my WSH Help file.

Well, it seems to be an overloaded operator that does different things
depending what you use it on.

Cheers
Ken

"George Hester" <he********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when
was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #7
"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
Apparently since version 1 of VBScript according to my WSH Help file.

Well, it seems to be an overloaded operator that does different things
depending what you use it on.

Cheers
Ken

There's also this behaviour:

Dim sPlus, sAmpersand
sPlus = "Hello " + Null
sAmpersand = "Hello " & Null
WScript.echo sPlus & ""
WScript.echo sAmpersand & ""

Addition sign and Null gives Null, ampersand and Null treats Null as empty
string.

--

Joe

Jul 19 '05 #8
CJM
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:u$*************@TK2MSFTNGP11.phx.gbl...
Aaron Bertrand [MVP] wrote:
I don't think George is trying to state that this isn't
well-documented. I think he is just implying (and I tend to agree)
that the default recommendation for string operations be +
:-)
No, that is your interpretation of what George was saying. I think "It may
help if someone at Microsoft knows how to write VBScript." is a pretty

clear statement. And a very incorrect statement in this case. :-)


Actually, I agree with you both.

I agree George said what Bob said, but I think George meant what Aaron said
he meant...! George...??

Personally agree with Aaron. And Bob.

....er, I think.

Yes '+' is overloaded, and thus can be used fairly in this example. But
surely '&' would be the better default choice.

Chris
Jul 19 '05 #9
It's overloaded and confusing.

<%@ Language=VBScript %>
<%
Option Explicit
dim an, a, eq, e, plus
an = "&" + "&"
a = "&"
eq = "=" & "="
e = "="
plus = "+"
%>
<script type="text/vbscript">
sub alertit(a, b)
msgbox "" & a + "<%=eq%>" + b & "<%=e%>TRUE", 64, "TRUE"
end sub
</script>
<script type="text/javascript">
var a<%=e%>"<%=a%>" <%=plus%> "<%=a%>", b<%=e%>"<%=an%>";
if(a <%=eq%> '&&' <%=an%> b <%=eq%> '&&') {
alert("a" <%=plus%> "<%=eq%>" <%=plus%> "b" <%=plus%> "<%=e%>" <%=plus%>
"TRUE");
alertit(a, b);
}
</script>

"CJM" <cj*****@yahoo.co.uk> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:u$*************@TK2MSFTNGP11.phx.gbl...
Aaron Bertrand [MVP] wrote:
I don't think George is trying to state that this isn't
well-documented. I think he is just implying (and I tend to agree)
that the default recommendation for string operations be +
:-)
No, that is your interpretation of what George was saying. I think "It may
help if someone at Microsoft knows how to write VBScript." is a pretty

clear statement. And a very incorrect statement in this case. :-)


Actually, I agree with you both.

I agree George said what Bob said, but I think George meant what Aaron said
he meant...! George...??

Personally agree with Aaron. And Bob.

....er, I think.

Yes '+' is overloaded, and thus can be used fairly in this example. But
surely '&' would be the better default choice.

Chris

Jul 19 '05 #10
Dang all I know is that the sample didn't work with "+" and did with "&." Must be something else I did then to make it work for it didn't as written. Of course I hooked it up to my own DSN.

--
George Hester
__________________________________
"George Hester" <he********@hotmail.com> wrote in message news:#L**************@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #11
Response.Write iCnt + " <a href=""http://" + rs(1) + """ target=_new>" + rs(1) + "</a><BR>"
Response.Write iCnt & " <a href=""http://" & rs(1) & """ target=_new>" & rs(1) & "</a><BR>"
No problem.

Note there are enough strings in here to show that coersion should not be an issue.

--
George Hester
__________________________________
"George Hester" <he********@hotmail.com> wrote in message news:#L**************@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #12
This sounds crazy... when did developers @ microsoft started mixing
languages... which is even not permitted in .NET :)

Keyur Shah
Verizon Communications
732-423-0745

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #13
keyur shah wrote:
This sounds crazy... when did developers @ microsoft started mixing
languages... which is even not permitted in .NET :)


Again: they didn't "+" is a perfectly good concatenation character in
vbscript. I've already posted a link to the documentation in this thread.

That said, I always use "&" for concatenation in vbscript. This habit really
burns me when I'm writing jscript code ...

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #14
As previously noted in this thread, "+" and "&" handle Nulls differently. Is there a possibility that any of the fields in your recordset contain Null?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
"George Hester" <he********@hotmail.com> wrote in message news:eY**************@TK2MSFTNGP11.phx.gbl...
Response.Write iCnt + " <a href=""http://" + rs(1) + """ target=_new>" + rs(1) + "</a><BR>"
Response.Write iCnt & " <a href=""http://" & rs(1) & """ target=_new>" & rs(1) & "</a><BR>"
No problem.

Note there are enough strings in here to show that coersion should not be an issue.

--
George Hester
__________________________________
"George Hester" <he********@hotmail.com> wrote in message news:#L**************@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #15

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl...

Again: they didn't "+" is a perfectly good concatenation character in
vbscript. I've already posted a link to the documentation in this thread.

That said, I always use "&" for concatenation in vbscript. This habit really burns me when I'm writing jscript code ...


Have you coded in php at all? That's the stupidest concatenator I've ever
seen. . It goes against all my instincts, but that's just because I was
raised in a Microsoft family, I guess.

Ray at work
Jul 19 '05 #16
Ray at <%=sLocation%> wrote:
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl...

Again: they didn't "+" is a perfectly good concatenation character
in vbscript. I've already posted a link to the documentation in this
thread.

That said, I always use "&" for concatenation in vbscript. This
habit really burns me when I'm writing jscript code ...
Have you coded in php at all?


Nope.
That's the stupidest concatenator I've
ever seen. .


Uuuum - what concatenator are you talking about?

Bob

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #17

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Have you coded in php at all?


Nope.
That's the stupidest concatenator I've
ever seen. .


Uuuum - what concatenator are you talking about?


..

$var1="Bob";
$var2="Barrows";
$var3=$var1." ".$var2;

Ray at work

Jul 19 '05 #18
> $var3=$var1." ".$var2;

Yeah, that's sexy.

Uh, wait, no it's not.
Jul 19 '05 #19
Ray at <%=sLocation%> wrote:
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Have you coded in php at all?


Nope.
That's the stupidest concatenator I've
ever seen. .


Uuuum - what concatenator are you talking about?


.

$var1="Bob";
$var2="Barrows";
$var3=$var1." ".$var2;


Ughhhh!

Bob
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #20
Bob Barrows wrote:
Ray at <%=sLocation%> wrote:
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Have you coded in php at all?

Nope.

That's the stupidest concatenator I've
ever seen. .

Uuuum - what concatenator are you talking about?


.

$var1="Bob";
$var2="Barrows";
$var3=$var1." ".$var2;


Ughhhh!


exactly ;o)

$var1="Bob";
$var2="Barrows";

$var3 = $var1;
$var3 .= " ";
$var3 .= $var2;

produces the same result

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #21

"William Tasso" <ne****@tbdata.com> wrote in message
news:eU**************@TK2MSFTNGP12.phx.gbl...

exactly ;o)

$var1="Bob";
$var2="Barrows";

$var3 = $var1;
$var3 .= " ";
$var3 .= $var2;

produces the same result


This further exposes my mother tongue. I never think of the += type of
things, even when I'm doing a set /a in a batch file. I suck.

Ray at work
Jul 19 '05 #22
Nope. No nulls.

--
George Hester
__________________________________
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message news:#L**************@TK2MSFTNGP11.phx.gbl...
As previously noted in this thread, "+" and "&" handle Nulls differently. Is there a possibility that any of the fields in your recordset contain Null?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
"George Hester" <he********@hotmail.com> wrote in message news:eY**************@TK2MSFTNGP11.phx.gbl...
Response.Write iCnt + " <a href=""http://" + rs(1) + """ target=_new>" + rs(1) + "</a><BR>"
Response.Write iCnt & " <a href=""http://" & rs(1) & """ target=_new>" & rs(1) & "</a><BR>"
No problem.

Note there are enough strings in here to show that coersion should not be an issue.

--
George Hester
__________________________________
"George Hester" <he********@hotmail.com> wrote in message news:#L**************@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________
Jul 19 '05 #23
OK, you've intrigued me. I am going to try to reproduce this on my machine.
It's an Access database, right? Can you give me an example of the data that
produces this error... wait a minute. I bet I know what the issue is. Let me
go and test it. I'll be right back ...

No, that's not it. I thought that the failure to explicitly specify the
field's value property was causing the problem, i.e.:

Response.Write rs(0) + "<BR>"
vs
Response.Write rsFields(0).value + "<BR>"

but that turned out not to be the problem - both of these statements worked
well for me. So the only alternative is that in your table, rs(0) is not a
Text column. In fact, using a numeric column was the only way I could
reproduce your error:

rs.Open "SELECT NumberColumn FROM tblblogs",cn, _
,,adCmdText
Response.Write rs(0) + "<BR>"

I made a mistake in my first reply in this thread. If you go back and
re-read the documentation
(http://msdn.microsoft.com/library/en...ncatenation.as
p), you will see that when a number and a string are the addends of the +
operator, addition is attempted, not concatenation. So,

Response.Write 1 + "<BR>"
will cause a type mismatch, since "<BR>" cannot be coerced to a number.

Response.Write 1 + "1"
will result in 2

Response.Write Cstr(1) + "1"
will result in "11"

To reiterate, when using the + operator, concatenation only occurs when both
addends are strings.

Using & will cause both addends to be converted to strings, no matter what
datatype they are initially, so concatenation will always occur.

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #24
Bob Barrows wrote:
Response.Write rsFields(0).value + "<BR>"

should be
Response.Write rs.Fields(0).value + "<BR>"
Jul 19 '05 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Otto Haldi | last post by:
Hello to all I'm using PHP since a few week. I like to know how php programmers are making so nice border to displaying MySQL table? I like to make a border with rounded corner. Could...
4
by: Dominik | last post by:
I'm looking for some nice-looking DHTML select boxes (combo boxes). Someone knows where can I find it?
0
by: Derek LaZard | last post by:
The ClipBoard Ring in the ToolBox is really a nice feature. Renaming, copying/moving within clipboard, and categorizing is a nice and frequently used feature... :) Derek LaZard
4
by: Reiter Peter | last post by:
hi can someone tell me, how i can create a really nice looking app? with nice effects do i need for this MDX (managed directx), or is it also possible with gdi+? for instance, windows media...
10
by: Justin Dutoit | last post by:
Hey. I'm still not experienced at error handling, and I need to know if Try.. Catch blocks are meant to be used to handle errors in your own app, ie bugs. Or, are they only for external things like...
8
by: Spleenwort | last post by:
With regard to XML comments in c#. I think that #regions should be self-documenting relative to XML comments or that a <region> tag should be defined and auto-inserted when you type #region...
7
by: shapper | last post by:
Hello, Does anyone knows where can I find some nice styled CSS tables? Thanks, Miguel
0
by: Pretty nice site, wants to see much more on it!,Pr | last post by:
Pretty nice site, wants to see much more on it!,Pretty nice site, wants to see much more on it!,Pretty nice site, wants to see much more on it!
3
by: WebCM | last post by:
How to apply nice URL-s into CMS? 1. Should we use nice urls for every page? 2. Do we need to put a FULL path into <a href="">? 3. What is faster and better? a) 10 rules in .htaccess...
3
by: sheldonlg | last post by:
I think this capability is lacking in php. Suppose there is a group of checkboxes all named "procedure". Doing a $_POST returns all the ones that are checked and not the ones that are not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.