Quote:
Originally Posted by FordGT90Concept
And let me give you a tip to cut down on the repetitiveness of your code. You can write a sub like this to perform all those checks:
Code:
Private Function Validate(ByRef obj As TextBox) As Double
If (obj.Text.Length > 0) Then
Dim value As Double = Convert.ToDouble(obj.Text)
If (value.Text > 10) Then
obj.BackColor = Color.Pink
MsgBox("Value must be between 1 and 10.")
Else
obj.BackColor = Color.White
Return value
End If
End If
End Function
Then to validate a control, you'd just have to do the following:
You can play with that concept to make it how you like it. It cuts way down on the repetition. 
|
Where would I put this code? Would it be in my form load or my txtbox1 or in my button (process order)?
As it says " 'Return' Statement in a sub or a set cannot return a value"