Skip to content

Instantly share code, notes, and snippets.

@halcwb
Created July 27, 2023 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halcwb/3d9c9f84818346884adabc2066144735 to your computer and use it in GitHub Desktop.
Save halcwb/3d9c9f84818346884adabc2066144735 to your computer and use it in GitHub Desktop.
Calculate the ventilation index
Sub Main
Console.WriteLine(CalcVentilationIndex(50, 25, 10, 15))
End Sub
' Calculate the ventilation index. Returns -1 if calculation not possible
' VI = (PaCO2 * (PIP - PEEP) * rate) / 1000
Function CalcVentilationIndex(dblPaCO2 As Double, dblPIP As Double, dblPEEP As Double, intRate As Integer) As Double
Dim dblVI As Double = -1
If dblPaCO2 > 0 And dblPIP > 0 And dblPEEP > 0 And intRate > 0 Then
dblVI = (dblPaCO2 * (dblPIP - dblPEEP) * intRate) / 1000
End If
Return dblVI
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment