Results 1 to 12 of 12

Thread: PLease HELP ME!! AAAARG

Threaded View

  1. #1

    Thread Starter
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375

    Question PLease HELP ME!! AAAARG

    I'm not sure if i should even post this, but here it is. What i need to do is calculate freeze-thaw cycles based on some data. What that means (for those that dont know) is that i have temperature data in an array. I need to know how many times the data goes below and comes back above a certain threshold, usually 0. This is a VB6 function that is supposed to do that. Please point out any obvious mistakes i might have made (btw it doesnt work right now).
    VB Code:
    1. Function FreezeThaw(ByRef iData() As Single, Threshold As Single) As Long
    2. Dim iMax As Long
    3. Dim i As Long
    4. Dim Cycles As Long
    5. Dim LastNum As Long
    6. Dim Num As Single
    7. Dim Num2 As Single
    8.  
    9. iMax = UBound(iData) - 1
    10. For i = 0 To iMax
    11.     Num = iData(i)
    12.     Num2 = iData(i + 1)
    13.    
    14.     'Make Sgn of num1
    15.     If Num > Threshold Then
    16.         Num = 1
    17.         LastNum = 1
    18.     ElseIf Num < Threshold Then
    19.         Num = -1
    20.         LastNum = 2
    21.     ElseIf Num = Threshold Then
    22.         Num = LastNum
    23.     End If
    24.    
    25.     'Make sgn of num2
    26.     If Num2 > Threshold Then
    27.         Num2 = 1
    28.     ElseIf Num2 < Threshold Then
    29.         Num2 = -1
    30.     ElseIf Num2 = Threshold Then
    31.         Num2 = Num
    32.     End If
    33.    
    34.     If Num * Num2 = -1 Then Cycles = Cycles + 1
    35. Next
    36. FreezeThaw = Int(Cycles / 2)
    37. End Function

    It works by making any number above the threshold a 1, and any number below the threshold a -1, and any number equal to the threshold the value of the last number. Then it multlplies one number by the next one. So if both are less than the threshold then the product is 1. If both are above then it is also 1. However, if one number is above and one below, the answer is -1 and i know there has been a crossing. Sorry 4 the long post. Thanks in avance.

    -Nishant
    Last edited by nishantp; Aug 28th, 2001 at 11:32 AM.
    You just proved that sig advertisements work.

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