Expression needs clarification please

fredfortsonsr

Registered User.
Local time
Today, 19:28
Joined
Apr 11, 2001
Messages
15
Hi,

I am reviewing the following code and the last four lines of code are confusing to me.

C(GasWork - 2) = C(GasWork - 2) + GasConc
If LowestDew(GasWork - 2) > DewPointNum Then
LowestDew(GasWork - 2) = DewPointNum
End If

If the Main Gas Symbol is "C6H14", "x" would equal "C6H" and Gas Work would equal "6".
Does C(GasWork - 2) mean C(4) or C4?
Or do I drop the C and just read it as (6-2) = (6-2) + .200 thus equaling 4.200?
Then, does LowestDew(6-2) just mean (6-2)? Then it would say:
If LowestDew(6-2) > .878 Then LowestDew(6-2) = 4
- - - - - - - - - - - - -
Counter = 0
DewPointNum = 2000
GasConc = .200
For i = 1 To 10
C(i) = 0
LowestDew(i) = 1800
Next
....

GasSymbol = GasInfo.Fields("Main Molecular Symbol")

If Mid(GasSymbol, 1, 1) = "C" And Val(Mid(GasSymbol, 2, 2)) > 3 And Mid(GasSymbol, 3, 1) <>
"+" Then
x = Mid(GasSymbol, 1, 3)

If Val(Right(x, 1)) > 0 Or Val(Right(x, 2)) = 10 Then
GasWork = Right(x, 2)
Else
GasWork = Mid(x, 2, 1)
End If

C(GasWork - 2) = C(GasWork - 2) + GasConc

If LowestDew(GasWork - 2) > DewPointNum Then
LowestDew(GasWork - 2) = DewPointNum
End If

It's a puzzle to me and any help would be appreciated.
Thanks,
Fred
 
i'll have a go, now let's see....

*looks like 'C' is a string array somewhere *in your db.

*Not sure what this line is doing, looks like it's setting an array element.

C(GasWork - 2) = C(GasWork - 2) + GasConc
*this just says if set the LowestDew
*(GasWork - 2) to DewPointNum if it exceeds *DewPointNum.
If LowestDew(GasWork - 2) > DewPointNum Then
LowestDew(GasWork - 2) = DewPointNum
End If

If the Main Gas Symbol is "C6H14", "x" would equal "C6H" and Gas Work would equal "6".
Does C(GasWork - 2) mean C(4) or C4?
*Answer C(4)
Or do I drop the C and just read it as (6-2) = (6-2) + .200 thus equaling 4.200?
*don't drop the C(),I think it is doing *something clever.
*Also I think LowestDew is a function or sub *procedure somewhere in your database, find *it and maybe you know where you're going *with this.

Then, does LowestDew(6-2) just mean (6-2)?
*No, again I think it is referring to the *key value in a string array.

Then it would say:
If LowestDew(6-2) > .878 Then LowestDew(6-2) = 4
- - - - - - - - - - - - -
Counter = 0
DewPointNum = 2000
GasConc = .200
*this is cycling through the array elements *of C and setting their values to 1800.

For i = 1 To 10
C(i) = 0
LowestDew(i) = 1800
Next
....
*This is setting GasSymbol string to equal *the value of figure/text in 'Main Molecular *Symbol'. Probably because the fields was *named and too mudh development had been *done before the original designer realised *how tedious it was typing Main Molecular *Symbol! Otherwise I think they would have *named it GasSymbol in the first place and *used the value directly in the formula.

GasSymbol = GasInfo.Fields("Main Molecular Symbol")
*You can use Left(GasSymbol,1) instead of
*Mid(GasSymbol, 1, 1) because it is starting *from the first letter


*Again we change Mid(GasSymbol, 1, 1) for *Left(GasSymbol,1)
If Mid(GasSymbol, 1, 1) = "C" And Val(Mid(GasSymbol, 2, 2)) > 3 And Mid(GasSymbol, 3, 1) <>
"+"
*The above checks if the first letter of Gas *Symbol is a "C" AND if the value of the *second two number in the string is greater *than 3 AND the fourth letter is not a plus
*("+") and continues to...
Then
*sets x to equal the last three letters of *GasSymbol.
x = Mid(GasSymbol, 1, 3)
*this check to see if x is 10 or below
If Val(Right(x, 1)) > 0 Or Val(Right(x, 2)) = 10 Then
*and if so sets the GasWork variable to the *number represented by the last two *characters in 'x'
GasWork = Right(x, 2)
Else
*otherwise set
GasWork = Mid(x, 2, 1)
End If

*still not sure what this is doing!
*what I think is that it is setting an array *element C() based on the value of element 2 *below it PLUS the GasConc value.

C(GasWork - 2) = C(GasWork - 2) + GasConc

*this just says if set the LowestDew
*(GasWork - 2) to DewPointNum if it exceeds *DewPointNum.

If LowestDew(GasWork - 2) > DewPointNum Then
LowestDew(GasWork - 2) = DewPointNum
End If

***PHEW!!!***
**After reading that I think my head is about to explode**
Seems to me you have some complicated maths going off there somewhere - but it's all a bit beyond me I'm afraid.

Ian
 
Fornatian,

heroic effort!

i think there should be a VBA equivalent to the International Obfuscated C Code Contest!
smile.gif


al
 

Users who are viewing this thread

Back
Top Bottom