Results 1 to 2 of 2

Thread: [RESOLVED] Math problem

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Resolved [RESOLVED] Math problem

    I getting erroneous results from a simple add and subtract loop. I'm sure it's something simple, but I don't see it.

    On the form is an array of textboxes and a label
    Code:
    private sub xxxxxxxx
        Dim Tot As Double
        Dim X As Integer
        Tot = 0
        For X = 1 To 8
            If TxtFld(X).Text <> "" Then
                If X <= 3 Then
                    Tot = Tot + CDbl(TxtFld(X).Text)
                Else
                    Tot = Tot - CDbl(TxtFld(X).Text)
                End If
            End If
        Next
        LblBal.Caption = CStr(Tot)
    end sub
    if txtfld(1) = 10
    & txtlfd(4) = 5
    & txtfld(6) = 5.1

    then it should be
    10 - 5 - 5.1 = -0.1
    but I get -9.99999 ?????

    what gives?

    -RT

    The actual answer given by vb is -9.99999999999943E-02
    Last edited by re_turner_jr; May 29th, 2009 at 08:20 AM. Reason: adding vb results

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