Left vs Left$ function

J

James Silverton

Andy wrote on Sat, 5 May 2007 05:25:00 -0700:

A> Can someone explain the difference between the two of these?
A> Thanks!

I don't seem to have LEFT$ in Excel 2002. When did it appear or
disappear? There *is* LEFTB that refers to double byte
characters like Chinese ones.

James Silverton
Potomac, Maryland

E-mail, with obvious alterations:
not.jim.silverton.at.comcast.not
 
G

Guest

I don't recall Excel having a LEFT$() worksheet function, BUT it is used in
VBA.

Here's the differece (as I understand it)

LEFT(string, num_chars) returns a VARIANT.

But, in LEFT$(string, num_chars), the trailing dollar sign ($) declares the
return value to be a STRING.

It would make a difference if the 1st argument could be null.

Example:
In the immediate window of the VB Editor....

If you enter DEBUG.PRINT LEFT(NULL,3)
This is returned: NULL

But, if you enter DEBUG.PRINT LEFT$(NULL,3)
you get this error: "Invalid use of null",
because a STRING cannot be null.

Does that help?
***********
Regards,
Ron

XL2002, WinXP
 
J

Jon Peltier

And the reason you'd use one or the other is that Left$ may be quicker if
all you're doing is manipulating strings, while Left would help if you're
going to encounter the situation Ron describes.

There are also such functions as Right$ and Mid$.

- Jon
 
G

Guest

Left$ and Right$ and Mid$ and other string operators are "left over" from the
days of BASIC. Ron and Jon have explained their use quite well. LEFT, RIGHT
etc are late comers to the world.

As you note, James, there is no LEFT$, RIGHT$, MID$ for the worksheet
itself, just in the innards of VB.
 
J

James Silverton

JLatham wrote on Sat, 5 May 2007 18:31:00 -0700:
Left$ and Right$ and Mid$ and other string operators are "left
over" from the
days of BASIC. Ron and Jon have explained their use quite
well. LEFT, RIGHT
etc are late comers to the world.

J> As you note, James, there is no LEFT$, RIGHT$, MID$ for the
J> worksheet itself, just in the innards of VB.

Ah, you've jogged my memory; it was BASIC! I had a feeling that
I had seen things like LEFT$ in computer languages of the dim
past :) I knew it wasn't Fortran, FOCAL, Algol or C but I had
not thought of BASIC!!

James Silverton
Potomac, Maryland

E-mail, with obvious alterations:
not.jim.silverton.at.comcast.not
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top