JoelTXCive
Civil/Environmental
- Jul 24, 2016
- 929
I am having problems sending an array into an excel function. I also may be having problems getting an array back out.
I'm trying to call a function named "Stem_Wind" and am passing several variables to this function. One of the variables is a 7x4 variant array.
After the function runs some calculations, the output of the function should be a 1x2 numeric array.
I think I have issues passing variables in to the function, but I probably have issues getting them back out too
...
Attached is the code... I can send more in text format if it helps.
Thank you in advance.
Here is the function CALL
And Here is the Actual Function:
I'm trying to call a function named "Stem_Wind" and am passing several variables to this function. One of the variables is a 7x4 variant array.
After the function runs some calculations, the output of the function should be a 1x2 numeric array.
I think I have issues passing variables in to the function, but I probably have issues getting them back out too
Attached is the code... I can send more in text format if it helps.
Thank you in advance.
Here is the function CALL
Code:
'Lets redim the array to add 2 more columns for wind shear and moments
ReDim Preserve StemArray(counter, 6)
'Set up Some Variables to use in the loop
Dim POI_Stem(2) As Double
Dim PointX As Double
'Loop through all my wall points and calculate shear and moments due to wind load
For i = LBound(StemArray, 1) To UBound(StemArray, 1)
PointX = StemArray(i, 4)
POI_Stem = Stem_Wind(PointX, POI_Special, h_topfence, h_parapet, pressure_wind)
StemArray(i, 5) = POI_Stem(1)
StemArray(i, 6) = POI_Stem(2)
Next i
And Here is the Actual Function:
Code:
Function Stem_Wind(PointX As Double, POI_Special() As Variant, h_topfence As Double, _
h_parapet As Double, pressure_wind As Double) As Double()
'
' This function will calculate shear and moments due to a uniform wind load
'
'
' Written by JoelTxCIVE
'
'
' Last Modified 07/10/2018
'
'INPUT:
'For each value sent into the function, we need to determine which region of the wall
'we are in and then apply the proper equation to determine shear and moments.
'
'PointX - This is the point I am interested in.
'POI_Special() - This is a (7x4) variant matrix with string and numeric columns
'h_topfence - Height of top of fence above wall
'h_parapet - Height of parapet region
'pressure_wind - Uniform wind pressure
'
'OUTPUT:
'A (1x2) array containing two numeric values. Value 1 will be shear and Value 2 is moment.
'We are going to use a select case operation to compare the PointX value
'to the special points of interest array.
Select Case PointX
Case Is < POI_Special(3, 4) 'in the top fence
Stem_Wind(1) = 0 'shear
Stem_Wind(2) = 0 'moment
Case Is = POI_Special(3, 4) 'at top of wall
Stem_Wind(1) = h_topfence * pressure_wind 'shear
Stem_Wind(2) = Stem_Wind(1) * h_topfence / 2 'moment
Case Is < POI_Special(4, 4) 'between top of wall and nat grade
Stem_Wind(1) = (h_topfence + PointX - POI_Special(3, 4)) * pressure_wind 'shear
Stem_Wind(2) = Stem_Wind(1) * PointX / 2 'moment
Case Is <= POI_Special(7, 4) 'below nat grade
Stem_Wind(1) = (h_topfence + h_parapet) * pressure_wind 'shear
Stem_Wind(2) = Stem_Wind(1) * (PointX - (h_topfence + h_parapet) / 2) 'moment
Case Else
Stem_Wind(1) = 0 'nothing
Stem_Wind(2) = 0 'nothing
End Select
End Function