CDbl function

  • Thread starter Thread starter snax500
  • Start date Start date
S

snax500

Can some one please explain how the CDbl conversion function works. I
have it in this code:

cell.Value = CDbl(sVal)

which converts 2000- to -2000.

How does this happen?

Thanks
 
for some reason, the person who programmed the cdbl conversion function put
in code to recognize a trailing hypen as a negative unary operator and so
interpret it. Beyond that, you would have to talk to the developers.

? cdbl("1200-")
-1200
? clng("1200-")
-1200
? cint("1200-")
-1200
? csng("1200-")
-1200
? cdec("1200-")
-1200
 
You have a function some one has developed for you. Check
Your macro to locate the function. If you do not find it
in your macro look for other references that yourmacro is
making one of your references has the function built into
it.

Off hand I would say it is so some thing of the sorts...

Dim suffix as string
suffix = right(var,len(var)-1)
NewVar = suffix & left(var,len(var)-1)

hope that helps,
-Neil
(e-mail address removed)
 
Actually, I took this from Tom's code when he posted it this week. I
just wanted someone to explain the "CDbl" function to me. I looked it
up in the help but I did not understand the explanation:

-1.79769313486231E308 to
-4.94065645841247E-324 for negative values; 4.94065645841247E-324 to
1.79769313486232E308 for positive values.


Thanks

For Each cell In Selection.SpecialCells( _
xlConstants, xlTextValues)
sVal = Trim(cell.Value)
If Right(sVal, 1) = "-" Then
cell.NumberFormat = "General"
cell.Value = CDbl(sVal)
End If
Next
 
double is a data type.

cdbl converts its argument to that type (a double).

The information you show tells you what size numbers can be stored in a
variable of type double.
 
Back
Top