Re: Does VBscript support " & _" for long strings?
- From: "Al Dunbar [MS-MVP]" <alan-no-drub-spam@xxxxxxxxxxx>
- Date: Fri, 19 Jan 2007 23:41:20 -0700
"Bob O`Bob" <filterbob@xxxxxxxxxxxxxxx> wrote in message
news:%23KPqiD0OHHA.4372@xxxxxxxxxxxxxxxxxxxxxxx
Al Dunbar [MS-MVP] wrote:to
My vote would be, no, it doesn't. If it did, then one would expect this
be legal:
const AB = "A" & "B"
but it's not.
/Al
works just fine in /real/ VB.
Also works fine in /real/ VBScript, it's just not the result one would
expect from a compiled language if one were unaware of the difference.
But this does propmt the question: what are you doing hanging out in a
newsgroup dedicated to what you might call /unreal/ VB? There's nothing
going on in the VB NG? ;-)
/Al
Bobdeallocation
MS MVP for VB, 2000-2006
"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote in message
news:OubNJGmOHHA.4244@xxxxxxxxxxxxxxxxxxxxxxx
Array manipulation is almost always more efficient than string
concatenation in vb/vbscript. Bear in mind that strings are not arrays
of characters: they are immutable objects in vbscript. That means that
each concatenation involves the creation of a new string along with the
destruction of the two addends. I.E., memory allocation and
thatoccurs for each concatenation: not an inexpensive operation.
However, there is a little controversy about whether
s = "a" & "b"
compiles to
s="ab"
relieving the runtime engine of the concatenation task. I have read
the compilers in some languages are smart enough to do this. I'm not
really sure if the vbs compiler is. Maybe Michael Harris will weigh in
...
Ed wrote:
I'm not sure if that would be efficient in this case, Bob. I'm not--
picking up the items one at a time - the list exists only in the
code. I'd have 40+ lines to set each item into an array position,
and _then_ Join them all into one string? Then I pick up my
text-to-look-for and use InStr to see if it's in the list. Then
again, I am the beginner here (which also means I don't always ask
questions right!), so if there's a better way to accomplish this
comparison, I'm all for it!
Ed
"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote in message
news:enE$xUlOHHA.140@xxxxxxxxxxxxxxxxxxxxxxx
In that case, you might want to consider assigning the items to an
array, using Join to combine them into the string.
Ed wrote:
Good thought, but in this case I just have one _really, really_ long--
string of items to Set right at the beginning of the code. Then as
I pick up text into another string, I do an InStr to see if my text
is in the collection.
Ed
"mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx> wrote in message
news:DRrrh.15588$X72.303@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Another thought:
This is just a matter of taste, but personally
I think it's cleaner, safer and easier to read
if it's done as a multiple concatenation:
s = "abc" & vbcrlf
s = s & "def" & vbcrlf
s = s & "ghi"
etc...
Ah! Thank you - my Copy and Paste may have done me in, then. I
will look
for that.
Ed
"Alexander Mueller" <millerax@xxxxxxxxxxx> wrote in message
news:u2Ric8jOHHA.2312@xxxxxxxxxxxxxxxxxxxxxxx
Ed schrieb:
"Michael Harris (MVP)" <mikhar.at.mvps.dot.org> wrote in message
news:%23ssqL4cOHHA.140@xxxxxxxxxxxxxxxxxxxxxxx
Ed wrote:
I know in Word and Excel VBA macros, I can set a long stringYes - _ as a line continuation character is supported in
using & vbCrLf & _
to continue the string on the next line. I seem to be getting
an error in a script using this. Then again, it may well be
something else. So I thought I'd check on this while I look
over everything else just to make sure this is okay in
scripting.
Thanks.
Ed
VBScript.
Thanks, Michael. At least now I know to look elsewhere for myNot that a trailing ' _' is legal in vb(a) but not in vbs.
problems.. 8>0
msgbox "hello" _
MfG,
Alex
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.
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.
.
- Follow-Ups:
- Re: Does VBscript support " & _" for long strings?
- From: Bob O`Bob
- Re: Does VBscript support " & _" for long strings?
- References:
- Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Michael Harris \(MVP\)
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Alexander Mueller
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: mayayana
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Bob Barrows [MVP]
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Bob Barrows [MVP]
- Re: Does VBscript support " & _" for long strings?
- From: Al Dunbar [MS-MVP]
- Re: Does VBscript support " & _" for long strings?
- From: Bob O`Bob
- Does VBscript support " & _" for long strings?
- Prev by Date: Re: How to escape out of a loop
- Next by Date: Re: Does VBscript support " & _" for long strings?
- Previous by thread: Re: Does VBscript support " & _" for long strings?
- Next by thread: Re: Does VBscript support " & _" for long strings?
- Index(es):
Relevant Pages
|