I tried posting this about an hour and a half ago but it
hasn't shown up so I'm posting it again.
Anyways,
I'm hoping someone can tell me the most efficient way to
do the following;
I have a character string which will always be six
charaters long (ie: "015478"). I need to evaluate the
expression and remove any leading zeros from it and
rewrite it as a character expression. Sometimes there will
be more than on leading zero and at times, there may not
be a leading zero.
I have a strong FoxPro background but am somewhat
unfamiliar with VB syntax and am hoping someone could
suggest the best way to do this.
Thanks in advance.
Ryan Gaudet
if you are sure it will always be numeric you can try: CStr(CLng("015478"))
"Ryan Gaudet" <rgau...@hotmail.com> wrote in message
news:074501c2ddf1$40cf27d0$8ef82ecf@TK2MSFTNGXA04...
Did you try it?
I guess if it isn't all digits (hex numbers for instance) and if you
want to keep it as a one-liner, then this is a possibility...
Replace$(LTrim$(Replace$("015478", "0", " ")), " ", "0")
<bg>
Rick - MVP
You're a sick boy Rick! <g>
Maybe we need to start a 12-step program for people who want to condense
everything to 1 line. Or should that be a 1-step program?
I'm many, many, many years past the age where "boy" might apply. On the
other hand, I would find it difficult indeed to argue with the word
"sick" as you intended it to be read (although I will point out that the
code **does** work<g>).
> Maybe we need to start a 12-step program for people who want to
> condense everything to 1 line. Or should that be a 1-step program?
One-step, of course; but I don't think I will participate in the
program... too worried about the withdrawal symptoms. <g>
Rick - MVP
? format$("00000015478","#")
J
--
The past does not repeat itself, but it rhymes.
Mark Twain
What I've ended up doing is simply taking the string with
the zeros (ie:"003456"), converting it into a numeric
value which removes the insignificant zeros automatically,
and then convert it back into a text string trimming any
spaces.
Although it may not be the "most efficient" or "right" way
to do it, I've tested it enough for the application I'll
be using it in.
Thanks again everyone and I have noted everyone's
suggestions in case my solution doesn't work out.
Ryan
>.
>
Ben