Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REReplace explanation

Status
Not open for further replies.

rlatham

Programmer
Aug 23, 2000
51
US
Could someone explain to me what the code below does and why it is throwing an error?
rRemoveLeadingZeros=true
rDecimalPlaces=true
strTemp=rValue=00000000986



Code:
if rRemoveLeadingZeros = True then
 strTemp = REReplace("^0+([0-9]{" & rDecimalPlaces + 1 & ",})$",strTemp,"$1")
 end if

'line 21
 strTemp = Left(strTemp,(Len(strTemp) - rDecimalPlaces)) & "." & Right(strTemp,rDecimalPlaces)

if rRemoveTrailingZeros = True then 
  strTemp = REReplace("([0-9\.]+)0+$",strTemp,"$1")
end if


Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Left'
/library\includes\functions\funcFormatMyNumber.inc.asp, line 21


Thanks in advance.
 
what is this:

Len(strTemp) - rDecimalPlaces))

Len(strTemp) returns the legnth of the strTemp and it is a number...

rDecimalPlaces is a boolean value...

how can you subtract both...

-DNG
 
I apologize,
rDecimalPlaces=2

Thanks for looking at my question.

 
Still can't figure out the problem, please help?
 
2nd argument for LEFT() function is invalid (less than zero).

Why that happens - post code for function ReReplace().

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Don't have the code for REReplace.. =(

I substituted REReplace for Replace and the page I needed displayed, but the content that REReplace has to removed, were displayed instead of the correct values. Like there was 1 step missing.

Example:
page displays: (0-9\.]+)0+$%
instead of:1190567
original value would be: 0000000001190567

Any thoughts ?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top