Since you called your class "datavalidation" it's rather hard with the information you have provided what function element needs to do what sort of validation. All that you have provided is a function that returns a TextBox with which you don't even use in your example.
Why not try something along these lines. I am not saying that this is the answer, but rather more food for thought.
Public class datavalidation
Public Function Validate_Fields(ByRef pWarehouseID As TextBox, ByRef pName As TextBox) as BOOLEAN
If pWarehouseID.Text = "" Or Not IsNumeric(pWarehouseID) Then
pWarehouseID.Text = "You have not entered the WareHouse ID? This is a mandatory field."
pWarehouseID.Focus()
pWarehouseID.Backcolor= Color.Red
return False
ElseIf pName.Text = "" Then
pName.Text="You have not entered the WareHouse Name? This is a mandatory field"
pName.Focus()
pName.Backcolor = Color.Red
return False
Else
return True
End If
End Function
Let me know if this the direction you want to go in. By the way in your pWarehouse_TextChanged reset the backcolor to the default color. Same thing with the pName_Textchanged.
This is not the only way on how to validate your fields. Be creative and have fun with it. :)
Edit: After submitting this answer I did a quick search here on CP and found this article. This might help you out. Keep on coding! :)
Validators for Windows Forms - ValidationProvider Control[
^]