Reputation: 1071
Originally I was using
Decimal.TryParse(input, New Decimal)
to figure out of user input is valid money. This works for most cases, except I only want to accept money within 2 digits, so "10.001" should not be accepted.
I looked all over SO for this simple and I imagine common issue but could not find an answer.
Upvotes: 0
Views: 184
Reputation: 1071
Mark in the discussion solved this for me. Thanks! Here's the VB.net code for what I was looking for:
Dim regex As Regex = New Regex("[0-9]?[0-9]?(\.[0-9]?[0-9]$)")
Dim match As Match = regex.Match(input)
If Not match.Success Then
Upvotes: 1