J
John Smith
Hello, I have a VB.NET application with a Windows form that have
several textboxes fields where I have dates entered. I would like to
do a date validation check after the the field is updated, so I' using
the leave event.
Right now I am creating a 'leave' sub for each of the fields.
However, I'd like to simplify that and just call the name of a
function and plug the field name as a variable and be done.
In other words, I would like to be able to pass the field name as the
variable to a function that will handle the field's leave event and
then run the validation check. If the validation check fails, set the
focus back to the field name.
This is my original code:
Private Sub OrderDate_Leave(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OrderDate.Leave
' Code that check whether there's a valid date goes here.
End Sub
What I would like to have is:
'calling the validation date function from any part of my code
CheckforDateValidation(fieldname)
With a function that goes like this:
Public function CheckForDateValidation(ByVal fieldname As String)
That will have the event: Handles fieldname.Leave
' Code that check whether there's a valid date goes here.
' and if the validation check fails then
' set the focus back to the field that called the function.
fieldname.focus
End function
Does anyone knows how to accomplish this?
Thanks!
several textboxes fields where I have dates entered. I would like to
do a date validation check after the the field is updated, so I' using
the leave event.
Right now I am creating a 'leave' sub for each of the fields.
However, I'd like to simplify that and just call the name of a
function and plug the field name as a variable and be done.
In other words, I would like to be able to pass the field name as the
variable to a function that will handle the field's leave event and
then run the validation check. If the validation check fails, set the
focus back to the field name.
This is my original code:
Private Sub OrderDate_Leave(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OrderDate.Leave
' Code that check whether there's a valid date goes here.
End Sub
What I would like to have is:
'calling the validation date function from any part of my code
CheckforDateValidation(fieldname)
With a function that goes like this:
Public function CheckForDateValidation(ByVal fieldname As String)
That will have the event: Handles fieldname.Leave
' Code that check whether there's a valid date goes here.
' and if the validation check fails then
' set the focus back to the field that called the function.
fieldname.focus
End function
Does anyone knows how to accomplish this?
Thanks!