The main subroutine returns lots of stuff unrelated to aircraft (eg., weather forecast, distances and headings between waypoints, etc.). Inside of this subroutine I have a set of functions to calculate various aircraft parameters such as true airspeed, fuel consumption, etc. which use a few static variables called from GetParams() which returns an array of values depending on type of aircraft pre-selected by the user from a drop-down list before running the main subroutine. Eg.:
Now I want to give user a choice to select different type of aircraft from the same drop-down list to update say GPH() values without re-running the whole subroutine, i.e. only to update selected functions concerning aircraft parameters only after running the main sub.
How can I do that?! Namely, how can I activate the "plane" variable without running the main sub when I select a different type of aircraft from the menu?
Thank you!
Rustam
Code:
Public Function GPH(PP As Integer, plane As Integer) As Double
'* Calculates cruise fuel consumption (gallons per hour)
'* Input: (i) "PP" as engine brake-power percentage; (ii) "plane" as type of aircraft
Dim AircraftData As Variant
AircraftData = GetParams(plane)
GPH = AircraftData(9) * PP ^ 2 + AircraftData(10) * PP + AircraftData(11)
End Function
Public Function GetParams(p_val As Integer) As Variant
'* Array contains static aircraft-specific data with the following parameters in order of declaration:
'
' Type of aircraft
' Max TOW (lbs)
' Ceiling (ft)
' Wing area (sq ft)
' Rated engine power (hp)
' Climb fuel variables (for function CFUEL) - 4 items
' Cruise fuel variables (for function GPH) - 3 items
' CoeffClimb (CL) variables (for function KTAS) - 4 items
' CoeffClimb derivative (CL)' variables (for function KTAS) - 4 items
' Startup and taxi fuel
Select Case p_val
Case 1
GetParams = Array("Cessna 172R Skyhawk", _
2450, _
12000, _
174, _
160, _
0.000000000003, -0.00000003, 0.00042, -0.0201, _
0.0002, 0.0901, 0.8544, _
0, 0.1257, -0.0333, 0.0454, _
0, 0.06285, 0.01665, -0.0681, _
1.1)
Case 2
GetParams = Array("Cessna 182T Skylane", _
3100, _
18000, _
174, _
230, _
0, 0.00000001, 0.0003, 0.1, _
0.0007, 0.0564, 4.796, _
-0.2215, 0.3476, -0.1113, 0.049, _
-0.33225, 0.1738, 0.05565, -0.0735, _
1.1)
End Select
End Function
Now I want to give user a choice to select different type of aircraft from the same drop-down list to update say GPH() values without re-running the whole subroutine, i.e. only to update selected functions concerning aircraft parameters only after running the main sub.
How can I do that?! Namely, how can I activate the "plane" variable without running the main sub when I select a different type of aircraft from the menu?
Thank you!
Rustam
Last edited: