#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    Convert to Double


    I'm having yet another problem converting code from VB6 to Python. This time it is with CDbl(). I read up on MSDN for what CDbl() does, I got the following example:
    Code:
    Dim MyCurr, MyDouble
    MyCurr = CCur(234.456784)              ' MyCurr is a Currency (234.4567).
    MyDouble = CDbl(MyCurr * 8.2 * 0.01)   ' Convert result to a Double (19.2254576).
    Now I don't know every feature that Python has that is like something that VB6 has. The only functions in VB6 such as CInt and CLng, I used int() for them in Python, however, with CDbl, this doesn't seem to be the case. The only Python function I thought of that could handle something like this was int(), only I still don't think that will work. Are there any other solutions?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,594
    Rep Power
    4207
    Code:
    def CDbl(foo):
        return float(foo)
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Thanks again Scorpions4Ever.

IMN logo majestic logo threadwatch logo seochat tools logo