## Nautical/Flight Functions

Functions perform various calculations useful for planning trips.

MPH2Kt: converts miles per hour to knots
Kt2MPH: converts knots to miles per hour
mi2NautMi: converts miles to nautical miles
nautMi2Mi: converts nautical miles to miles
minsInFlight: calculates total flight time in minutes
nautMiFlown: calculates the nautical miles flown
ktSpeed: calculates the average speed in knots
Hr2Min: converts hours to minutes
Snd2Min: converts seconds to minutes
galFuel: calculates the minimum number of gallons of fuel needed for a given trip time.

##### Public Not Tested Not My Work
' MPH2Kt: converts miles per hour to knots
' Kt2MPH: converts knots to miles per hour
' mi2NautMi: converts miles to nautical miles
' nautMi2Mi: converts nautical miles to miles
' minsInFlight: calculates total flight time in minutes
' nautMiFlown: calculates the nautical miles flown
' ktSpeed: calculates the average speed in knots
' Hr2Min: converts hours to minutes
' Snd2Min: converts seconds to minutes
' galFuel: calculates the minimum number of gallons of fuel needed for a given trip time.

Function MPH2Kt(ByVal mph)'miles per hour to knots
'purpose: converts miles per hour to knots
'arguments:            mph                        miles per hour as double
'returns:             double                    knots to miles per hour
MPH2Kt = cdbl(cdbl(mph) / 1.152)
End Function

Function Kt2MPH(ByVal kt) 'knots to miles per hour
'purpose: converts knots to miles per hour
'arguments:            knots                        knots as double
'returns:             double                    miles to nautical miles
Kt2MPH = cdbl(1.152 * cdbl(Kt))
End Function

Function mi2NautMi(ByVal miles) 'miles to nautical miles
'purpose: converts miles to nautical miles
'arguments:         miles            miles as double
' returns:            double        nautical miles to miles
mi2NautMi = cdbl((cdbl(miles) * 5280) / 6076.1)
End Function

Function nautMi2Mi(ByVal nautMi) 'nautical miles to miles
' purpose: converts nautical miles to miles
' arguments:        nauticalmiles            nautical miles as double
' returns:            double                    flight time in minutes
nautMi2Mi = cdbl((cdbl(nautMi) * 6076.1) / 5280)
End Function

Function minsInFlight(ByVal nautMi, ByVal kt) 'flight time in minutes
' purpose: calculates total flight time in minutes
' arguments:        nauticalmiles            nautical miles to travel as double
'                        knots                        air speed in knots as double
' returns:            double                    nautical miles flown
MinsInFlight = cdbl((cdbl(nautMi) / cdbl(kt)) * 60)
End Function

Function nautMiFlown(ByVal kt, ByVal mins) 'nautical miles flown
'purpose: calculates the nautical miles flown
'arguments:            knots                        air speed in knots as double
'                        minutes                    minutes elapsed as double
'returns:            double                    average speed in knots
NautMiFlown = (cdbl(mins) / 60) * cdbl(cdbl(kt))
End Function

Function ktSpeed(ByVal nautMi, ByVal mins) 'average speed in knots
'purpose: calculates the average speed in knots
'arguments:            nauticalmiles            nautical miles travelled as double
'                        minutes                    minutes elapsed as double
'returns:            double                    hours to minutes
ktSpeed = cdbl(cdbl(nautMi) / (cdbl(mins) / 60))
End Function

Function Hr2Min(ByVal hr) 'hours to minutes
'purpose: converts hours to minutes
'arguments:            hour                        hours as double
'returns:            double                    seconds to minutes
Hr2Min = cdbl(cdbl(hr) * 60)
End Function

Function Snd2Min(ByVal sd) 'seconds to minutes
'purpose: converts seconds to minutes
'arguments:            seconds                    seconds as double
'returns:            double                    gallons of fuel needed
Snd2Min = cdbl(cdbl(sd) / 60)
End Function

Function galFuel(ByVal mins, ByVal gph) 'gallons of fuel needed
' purpose: calculates the minimum number of gallons of fuel needed for a given trip time.
' arguments:        minutes                    minutes as double
'                        gallonsPerHour            gallons per hour consumed by craft as double
'returns:            double
galFuel = cdbl((cdbl(mins) / 60) * gph)
End Function

ByVal mph
ByVal kt
ByVal miles
ByVal nautMi
ByVal nautMi, ByVal kt
ByVal kt, ByVal mins
ByVal nautMi, ByVal mins
ByVal hr
ByVal sd
ByVal mins, ByVal gph