Is there anybody which can assist me with a code in VB.NET visual studio 2010 for validating Greek TAX Registration number (VAT).
It's not EU laws that makes it 9 digits, it depends on the country.
Unfortunately I don't know if you can get hold of the algorithm anywhere and even if you could, that still wouldn't mean that it was a valid VAT number. The only way that I know of to be sure that it's a valid VAT number is to validate it against the webservice as mentioned in Rup's comment. So if you're going to use this validation to decide if you're going to charge VAT or not, I'd not trust just a calculation since then you might end up breaking the rules (and possibly having to pay VAT that you haven't collected...).
There's a code project article showing how to use it (C# but should be relatively easy to convert to VB.Net if needed): VIES - VAT number checker
Though obviously it might be worthwhile checking for 9 digits first to rule out any obviously invalid ones.
As it is mentioned here you won't get the complete validation because "the European Commission cannot divulge these algorithms". However greece Vat must have a 9 digits block. So it might suffice to check this with a Regex:
Dim text As String = Me.TxtVAT.Text
Dim regex As New System.Text.RegularExpressions.Regex("^\d{9}$", System.Text.RegularExpressions.RegexOptions.Compiled)
If regex.IsMatch(text) Then
'do something'
Else
'do something else'
End If
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With