I have the following code to validate two text box entries to make sure that they are valid dates. My problem is that I cannot figure out how to pass the text box value as an argument so I can use the method to handle the text validation of two different text boxes. Here is what I have so far:
Private Sub txtBirthdate_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles txtBirthdate.Validating, txtSpouseBirthday.Validating
Try
If String.IsNullOrWhiteSpace(sender.ToString) Then
'Do Nothing
Else
Dim ReturnDate As DateTime
ReturnDate = validator.CheckIsValidDate(sender.ToString)
txtBirthdate.Text = ReturnDate.ToShortDateString
End If
Catch ex As Exception
Throw
End Try
End Sub
Thanks!
You need to cast the
senderobject to aTextBoxto get at the properties: