BlakeMcKenna
asked on
UserControl is "Nothing"?
I am trying to pass one of three different kinds of UserControls into the below SubProcedure and based on the value of the "testType" parameter, the "uc" will get set accordingly. My problem, however, is that the value of "uc" is Nothing when it enters the Try Catch even though it was assigned as a "userLoad", "userCreep" or "userRepeat" UserControl. How can I capture the appropriate UC when passed in?
Thanks!
Thanks!
Private Sub ValidateLoadEnvironmentValues(uc As UserControl, testType As String)
Select Case testType
Case "Load"
uc = DirectCast(uc, userLoad)
Case "Creep"
uc = DirectCast(uc, userCreep)
Case "Repeat"
uc = DirectCast(uc, userRepeat)
End Select
Try
EH.ErrorMessage = String.Empty
GetEnvironmentReadings(uc, testType)
If EH.ErrorMessage = String.Empty Then
AreTestsComplete(uc)
End If
ProcessMessage:
Catch ex As Exception
EH.ErrorMessage = "frmCalibration_3/ValidateLoadEnvironmentValues() - " & ex.Message & "...Contact Engineering!" & "~E"
End Try
End Sub
What does "GetEnvironmentReadings()" do? Lines like this "uc = DirectCast(uc, userLoad)" don't actually the type of "uc". It's still a generic UserControl when you pass it. If Nothing is the problem, it is most likely getting passed in as Nothing...
ASKER
It actually references several controls from within the "uc" and then makes another call to a function. The signature parameter "uc" actually does contain a valid UserControl instance .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know where your coming from Mike...and makes sense in a normal situation. However, ValidateLoadEnvironmentVal ues is a SubProcedure that is the object of an "AddressOf" in the dynamic creation of the UserControls. Anyway, I think I figured it out!
ASKER
Thanks for the input Mike!