Results 1 to 2 of 2

Thread: This problem is driving me sane.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    USA
    Posts
    20

    Unhappy This problem is driving me sane.

    Okay, this problem has me extremely confused.

    Below I will post a function out of my code and astrick the portion that I believe is having problems. I will post the whole function (it is a small one) just incase I am missing something.

    Basically it is a very simple proccess that adds and divides some numbers... shouldn't be difficult and yet when I run the program the results that are reported are completely wrong. Anyone see what I am missing?

    Thanks

    Code:
    Function specialistCombine()
       Dim tempOne(9) As String
       Dim tempTwo(9) As String
    
    ' added tempVal to try and track where the error occurs.
       Dim tempVal As Single
    
       Dim currentSymbol As String = data(0, 0)
       Dim startSymbol As Integer = 0
       Dim counting As Integer = 0
       Dim countingToo As Integer
       Dim countingAlso As Integer = dataCount + 1
    
            For symbolPosition = 0 To dataCount
                If data(symbolPosition, 0) = currentSymbol Then
    
                Else
                    For countingToo = startSymbol To symbolPosition - 1
                        If data(countingToo, 7) = "B" Then
             tempOne(0) = data(countingToo, 0)
             tempOne(7) = data(countingToo, 7)
             tempOne(6) = "Boston Exchange"
             tempOne(2) = Val(tempOne(2)) + Val(data(countingToo, 2))
     
    ****************************************************
    ' THIS IS WHERE THE PROBLEM IS. The results of tempOne(1) 
    ' are not correct. I have verified that tempOne(2), data
    ' (countingToo, 1) and data(countingToo, 2)  are correct at 
    ' this point and also that tempOne(1) does start at a val() of 0.
    ' The numbers that I get (and the number that is reported by the 
    ' SEC) are different than the results that are created here.
    
    tempVal = (Val(data(countingToo, 1)) * Val(data(countingToo, 2)))
    tempVal = tempVal + (Val(tempOne(1)) * Val(tempOne(2)))
    tempOne(1) = (tempVal / Val(tempOne(2)))
    
    ****************************************************
    
                        End If
                        If data(countingToo, 7) = "C" Then
               tempTwo(0) = data(countingToo, 0)
               tempTwo(7) = data(countingToo, 7)
               tempTwo(6) = "Cinn. Exchange"
               tempTwo(2) = Val(tempTwo(2)) + Val(data(countingToo, 2))
    **************************************************** '  The Problem also occurs here.
     
    tempTwo(1) = (Val(data(countingToo, 1)) * Val(data(countingToo, 2))) + (Val(tempTwo(1)) * Val(tempTwo(2)))
    tempTwo(1) = (Val(tempTwo(1)) / Val(tempTwo(2)))
    ****************************************************
    
                        End If
                    Next
                    If tempOne(0) = currentSymbol Then
                        data(countingAlso, 0) = tempOne(0)
          data(countingAlso, 1) = Format(Val(tempOne(1)), "0.000000")
         data(countingAlso, 2) = Format(Val(tempOne(2)), "00000000")
                        data(countingAlso, 6) = tempOne(6)
                        data(countingAlso, 7) = tempOne(7)
                        countingAlso = countingAlso + 1
                    End If
                    If tempTwo(0) = currentSymbol Then
                        data(countingAlso, 0) = tempTwo(0)
          data(countingAlso, 1) = Format(Val(tempTwo(1)), "0.000000")
          data(countingAlso, 2) = Format(Val(tempTwo(2)), "00000000")
                        data(countingAlso, 6) = tempTwo(6)
                        data(countingAlso, 7) = tempTwo(7)
                        countingAlso = countingAlso + 1
                    End If
                    startSymbol = symbolPosition
                    currentSymbol = data(symbolPosition, 0)
                    For counting = 0 To 9
                        tempOne(counting) = 0
                        tempTwo(counting) = 0
                    Next
                End If
            Next
            dataCount = countingAlso
            data = sort(data, dataCount, 7)
        End Function
    Last edited by Harbinger; Apr 19th, 2002 at 10:21 AM.

  2. #2
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    please do us a favor and place around your code. It makes it easier to read.
    thanks

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