|
I would like to pass the name of a control to a sub for control validation. I have a great quantity of controls and don't want to code validation over and over. I have tried the following code, but keep getting errors. I'm new to vb.net and appreciate the help. Am I on the right track? Thanks.
Mark F.
Private Sub txtEnterNumber(....) valnums(txtEnterNumber) End Sub
Private Sub valnums(ByVal name) Dim strTest As String = name If strTest.Text = "" Then MessageBox.Show("The name Value is required.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error) With strTest .Text = Nothing .Focus() End With
ElseIf Not IsNumeric(strTest.Text) Then MessageBox.Show("The name Value must be numeric.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error) With strTest .Text = Nothing .Focus() End With End If End Sub |