Hey everyone,
I have many functions that perform mathematical calculations.
Here is one for example:
Code:
Public Function internaldiamofcasingpipecalculation(ByVal Externaldiameterofcarrierpipe As Double, ByVal insulationthickness As Double) As Double

        Dim InternalDiameterofCasingPipe = Externaldiameterofcarrierpipe + 2 * (insulationthickness / 1000)

        Return InternalDiameterofCasingPipe
    End Function
Now in the next function I need to use the returned value of the previous function " InternalDiameterofCasingPipe":
Code:
Public Function externaldiamofcasingpipe(ByVal internaldiameterofcasingpipe As Double, ByVal jacketthickness As Double) As Double

        Dim ExternalDiameterofCasingPipe = internaldiameterofcasingpipe + 2 * (jacketthickness / 1000)

        Return ExternalDiameterofCasingPipe
    End Function
So the problem is while I am debugging I put a break point and found that the first function taht calulates the InternalDiameterofCasingPipe works fine. But when I check the value of InternalDiameterofCasingPipe in the second function its value is 0... Why is this? Is there a specific way to use the values returned by a function?

Here is the function that calls the calculations in order:
Code:
Public Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click

        ' 1. Check if Metric or Imperial Units are selected.
        ' 2. Convert Entered Variables to opposite unit.
        ' 3. Determine what type of pipe is selected
        ' 4. Determine what type of casing is selected.
        ' 5. Perform Required Calculations & display them

        If optMetric.Checked Then


            Call ConvertVariableToImperial(SoilTemp, SupplyTemp, CarrierPipeWallThickness, InsulationThickness, JacketThickness, Externaldiameterofcarrierpipe, LayingDepthtoTopofPipe, TotalLengthofPipeRun,
                                           FlowRate, Temperaturetoreach)

            Call choosepipecomboboxcoding(cboChoosePipe,
                                                   HDPE,
                                                   PVC,
                                                   ABS,
                                                   FRP,
                                                   Copper,
                                                   Steel,
                                                   Ductileiron,
                                                   ImperialHDPE,
                                                   ImperialPVC,
                                                   ImperialABS,
                                                   ImperialFRP,
                                                   ImperialCopper,
                                                   ImperialSteel,
                                                   ImperialDuctileIron)
            choosecasingcomboboxcoding(cboChooseCasingPipe, HDPE, GalvanizedSteel, Aluminum, PVC, Steel, ImperialHDPE, ImperialGalvanizedSteel, ImperialAluminum, ImperialPVC, ImperialSteel)


            InternalDiamCarrierPipeCalculation(Externaldiameterofcarrierpipe, CarrierPipeWallThickness)

            internaldiamofcasingpipecalculation(Externaldiameterofcarrierpipe, InsulationThickness)

            externaldiamofcasingpipe(InternalDiameterofCasingPipe, JacketThickness)

            layingdepthtocenterlineofpipecal(LayingDepthtoTopofPipe, ExternalDiameterofCasingPipe)

            crosssectionalareaofpipecal(Externaldiameterofcarrierpipe, CarrierPipeWallThickness)

            thermalresistanceofinsulationcal(ThermalConductivityofInsulation, InternalDiameterofCasingPipe, Externaldiameterofcarrierpipe)

            thermalresistanceofthecarrierpipecal(ThermalConductivityofCarrierPipe, Externaldiameterofcarrierpipe, InternalDiameterofCarrierPipe)

            thermalresistanceofthejacketpipecal(ThermalConductivityofCasingPipe, ExternalDiameterofCasingPipe, InternalDiameterofCasingPipe)

            thermalresistanceofsoilcal(ThermalConductivityofSoil, LayingDepthToCenterlineOfPipe, ExternalDiameterofCasingPipe)

            timetoreachtempcal(Temperaturetoreach, SoilTemp, SupplyTemp, InternalDiameterofCarrierPipe, ThermalResistanceofTheInsulation, ThermalResistanceOfTheCarrierPipe,
                               ThermalResistanceofTheJacketPipe, ThermalResistanceOfTheSoil)

            totalheatgainfromsoilonpiperuncal(TotalLengthofPipeRun, HeatGain)

            increaseinsupplytempatoutletcal(TotalHeatGainFromSoilonPipeRun, FlowRateImperial)




            Call HeatTransmissionCoefficientforAsinglePipeCalculation(ThermalResistanceofTheInsulation, ThermalResistanceOfTheCarrierPipe, ThermalResistanceofTheJacketPipe,
                                                                      ThermalResistanceOfTheSoil)

            Call HeatGainCalculation(HeatTransmissionCoefficientforASinglePipe,
                                     SoilTemp,
                                     SupplyTemp)


            Call VelocityCalculation(FlowRate, Externaldiameterofcarrierpipe, CarrierPipeWallThickness)


        ElseIf optImperial.Checked Then

            ImperialSoilTemp = SoilTemp
            ImperialSupplyTemp = SupplyTemp
            ImperialCarrierPipeWallThickness = CarrierPipeWallThickness
            ImperialInsulationThickness = InsulationThickness
            ImperialJacketThickness = JacketThickness
            ImperialExternaldiameterofcarrierpipe = Externaldiameterofcarrierpipe
            ImperialLayingDepthtoTopofPipe = LayingDepthtoTopofPipe
            ImperialTotalLengthofPipeRun = TotalLengthofPipeRun
            ImperialTemperaturetoreach = Temperaturetoreach
            FlowRateImperial = FlowRate

            Call ConvertVariablesToMetric(ImperialSoilTemp, ImperialSupplyTemp, ImperialCarrierPipeWallThickness, ImperialInsulationThickness, ImperialJacketThickness, ImperialExternaldiameterofcarrierpipe,
                                          ImperialLayingDepthtoTopofPipe, ImperialTotalLengthofPipeRun, ImperialTemperaturetoreach)

            Call choosepipecomboboxcoding(cboChoosePipe,
                                                  HDPE,
                                                  PVC,
                                                  ABS,
                                                  FRP,
                                                  Copper,
                                                  Steel,
                                                  Ductileiron,
                                                  ImperialHDPE,
                                                  ImperialPVC,
                                                  ImperialABS,
                                                  ImperialFRP,
                                                  ImperialCopper,
                                                  ImperialSteel,
                                                  ImperialDuctileIron)
            choosecasingcomboboxcoding(cboChooseCasingPipe, HDPE, GalvanizedSteel, Aluminum, PVC, Steel, ImperialHDPE, ImperialGalvanizedSteel, ImperialAluminum, ImperialPVC, ImperialSteel)


            InternalDiamCarrierPipeCalculation(Externaldiameterofcarrierpipe, CarrierPipeWallThickness)

            internaldiamofcasingpipecalculation(Externaldiameterofcarrierpipe, InsulationThickness)

            externaldiamofcasingpipe(InternalDiameterofCasingPipe, JacketThickness)

            layingdepthtocenterlineofpipecal(LayingDepthtoTopofPipe, ExternalDiameterofCasingPipe)

            crosssectionalareaofpipecal(Externaldiameterofcarrierpipe, CarrierPipeWallThickness)

            thermalresistanceofinsulationcal(ThermalConductivityofInsulation, InternalDiameterofCasingPipe, Externaldiameterofcarrierpipe)

            thermalresistanceofthecarrierpipecal(ThermalConductivityofCarrierPipe, Externaldiameterofcarrierpipe, InternalDiameterofCarrierPipe)

            thermalresistanceofthejacketpipecal(ThermalConductivityofCasingPipe, ExternalDiameterofCasingPipe, InternalDiameterofCasingPipe)

            thermalresistanceofsoilcal(ThermalConductivityofSoil, LayingDepthToCenterlineOfPipe, ExternalDiameterofCasingPipe)

            timetoreachtempcal(Temperaturetoreach, SoilTemp, SupplyTemp, InternalDiameterofCarrierPipe, ThermalResistanceofTheInsulation, ThermalResistanceOfTheCarrierPipe,
                               ThermalResistanceofTheJacketPipe, ThermalResistanceOfTheSoil)

            totalheatgainfromsoilonpiperuncal(TotalLengthofPipeRun, HeatGain)

            increaseinsupplytempatoutletcal(TotalHeatGainFromSoilonPipeRun, FlowRateImperial)



            Call HeatTransmissionCoefficientforAsinglePipeCalculation(ThermalResistanceofTheInsulation, ThermalResistanceOfTheCarrierPipe, ThermalResistanceofTheJacketPipe,
                                                                      ThermalResistanceOfTheSoil)

            Call VelocityCalculation(FlowRate, Externaldiameterofcarrierpipe, CarrierPipeWallThickness)


        Else
            ' Error Message Box Signaling the user if he forgets to mention the units
            MessageBox.Show("Please Select The Units You Are Working With.")

        End If





    End Sub
Thanks!!