Re: Left vs Left$ function

Tech-Archive recommends: Fix windows errors by optimizing your registry



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
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Ron Coderre" <RonCoderre@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BBD3C2D8-590E-45B1-B359-4A69906D0FB0@xxxxxxxxxxxxxxxx
I don't recall Excel having a LEFT$() work*** 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


"Andy" wrote:

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


.


Quantcast