Results 1 to 5 of 5

Thread: double as a counter

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2003
    Location
    uk
    Posts
    4

    Unhappy double as a counter

    i am getting funny results when i use a double as a counter

    Dim counter As Double
    For counter = 0 To 10 Step 0.1
    Debug.Print counter
    Next counter

    it works alright up to 5.9 then it goes to 5.99999999999999 and the error carries over.
    even though its not a large error i can't see why it goes it.
    any ideas?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Why would you want to use a double as a counter ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2003
    Location
    uk
    Posts
    4
    thanks kayjay those links really helped

    in reply to plenderj it seamed like a good idea at the time as i neaded to step in steps of 0.01 i was intergrating a funtion using that step length

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well you could loop with a Long and just pass the counter / 100 as the parameter or something ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

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



Click Here to Expand Forum to Full Width