I'm taking VB.net now and we're learning data validation. I'm so proud of this fuction I wrote!
Private Function ValidSalvageNumber(ByVal txtOjbect As TextBox, ByVal txtAssetCost As TextBox) As Boolean
Dim sng25PercAssetCost As Single
If IsNumeric(txtOjbect.Text) Then
sng25PercAssetCost = CSng(txtAssetCost.Text) * 0.25
sng25PercAssetCost = sng25PercAssetCost + CSng(txtAssetCost.Text)
If CSng(txtOjbect.Text) >= 0 And CSng(txtOjbect.Text) <= sng25PercAssetCost Then
errMessage.SetError(txtOjbect, "")
Return True
Else
errMessage.SetError _
(txtOjbect, "Number can not be less than 0 and has to be greater then 25% of the asset cost.")
Return False
End If
End If
End Function
Here is the program. Try it yourself!!
Nerd power!