Results 1 to 7 of 7

Thread: Problem with single(s)?

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    UK
    Posts
    36

    Unhappy

    The following code is used to compare two numbers:
    Dim sngValues(2) As Single
    Dim intAmount As Integer
    Dim sngTestValue As Single


    sngValues(0) = 63.7

    If round(100 * sngValues(0)) = 100 * sngValues(0) then
    msgbox "YES"
    else
    end
    endif

    Yet the msgbox for this particular number never occurs??????
    Any ideas???

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I tried your code and the message box appears for me.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    Singles

    Very odd!

    Have you tried re-booting...

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    UK
    Posts
    36

    Talking DOH!

    the number is 1.359293

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    What?!???

    what number, where, how, why - you've been fibbing again, haven't you....

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    UK
    Posts
    36

    Talking Me-I never lie!

    sngValues(0) = 1.359293
    If round(100 * sngValues(0)) = 100 * sngValues(0) then
    msgbox "YES"
    else
    end
    endif

    Sorry this is the correct bit of code, as to how and why not sure a colleague is using it and asked me to place it on this wonderful site for real VB programmers to ponder!

  7. #7
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Well it wouldn't work, would it?

    Round 135.9293 is 136 (i.e. <> 135.9293

    DOH...

    Use this to see what is going on...

    MsgBox Round(100 * sngValues(0)) & ", " & 100 * sngValues(0)

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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