Values aren't being returned in Sub-Procedure

I have a two subroutines where one calls the other and passes 2 parameters, however, on return, the parameters are empty and I'm not sure what I'm doing wrong.

Here are the two Sub Routines:

    Private Sub usrResistanceCreep_ResistanceButton() Handles usrResistanceCreep.ResistanceButton
        'Debug.Print("usrResistanceCreep_ResistanceButton")

        Try
            Dim strRin As String = String.Empty
            Dim strRout As String = String.Empty

            EH.ErrorMessage = String.Empty

            CheckTestRinRout(strRin, strRout)

            If strRin.Length > 0 Then
                usrResistanceCreep.txtRIn.Text = Format(CDec(strRin), "#####0.####")
            End If

            If strRout.Length > 0 Then
                usrResistanceCreep.txtROut.Text = Format(CDec(strRout), "#####0.####")
            End If

        Catch ex As Exception
            EH.ErrorMessage = "frmCalibration_3/usrResistanceCreep_ResistanceButton() - " & ex.Message & "...Contact Engineering!" & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
    End Sub
    '
    '
    '
    Public Sub CheckTestRinRout(ByVal strRIn As String, ByVal strROut As String)
        'Debug.Print("CheckTestRinRout")

        Try
            EH.ErrorMessage = String.Empty

            strMessage = "Acquiring Resistance In / Resistance Out values!"
            mlStatusMessage.Text = strMessage

            strRIn = String.Empty
            strRout = String.Empty

            Application.DoEvents()

            InitializeErrorClass(EH)
            ReadRin(RealReadMode, 0, EH)
            If EH.ErrorMessage = String.Empty Then
                strRIn = CStr(GetDecimalPlaces(CStr(EH.sSingle), gLoadDecimalPlaces))
            Else
                GoTo ProcessMessage
            End If

            If blnGetRout Then
                blnGetRout = False

                ReadRout(RealReadMode, 0, EH)

                If EH.ErrorMessage = String.Empty Then
                    strRout = CStr(GetDecimalPlaces(CStr(EH.sSingle), gLoadDecimalPlaces))
                End If
            End If

            If strRIn.Length > 0 And strRout.Length > 0 Then
                blnResiTestComplete = True

                If AreTestsComplete2() Then
                    btnSaveTestLoad.Focus()
                End If
            End If

            mlStatusMessage.Text = String.Empty

ProcessMessage:

        Catch ex As Exception
            EH.ErrorMessage = "frmCalibration_3/CheckTestRinRout() - " & ex.Message & "...Contact Engineering!" & "~E"
        End Try
    End Sub

Open in new window

BlakeMcKennaAsked:
Who is Participating?
 
ElrondCTCommented:
In Public Sub CheckTestRinRout(ByVal strRIn As String, ByVal strROut As String), change both ByVal to ByRef.

ByVal makes a copy of the data that you're passing, and leaves the original values unchanged. ByRef points to the original variable, so any change is passed to the calling procedure.
0
 
BlakeMcKennaAuthor Commented:
ElronCT, that worked great! I've used ByRef before but wasn't sure if that would take care of it. I should have tried it before posting!

Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.