Results 1 to 15 of 15

Maths using Double type

Threaded View

  1. #1
    Registered User
    Join Date
    09-26-2011
    Location
    Dumfries, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    5

    Maths using Double type

    Can anyone explain why relatively simple maths do not work in my sub when I have a variable declared as a type of Double?
    I have one declared as integer set as 3 and one declared as double set to 0.6.
    When I check if 3 * 0.2 = 0.6 I get a false... See sample sub below.

    Sub testIt()
    Dim FirstNumber As Double, SecondNumber As Integer
    FirstNumber = 0.6
    SecondNumber = 3
    If (SecondNumber * 0.2) = FirstNumber Then
        MsgBox "Worked"
    Else
        MsgBox "Not Worked >" & (SecondNumber * 0.2) & "<>" & FirstNumber & "<"
    End If
    
    End Sub
    Confused....
    Last edited by SteveCurrie; 09-27-2011 at 06:10 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1