Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Greek VAT validation number code

Is there anybody which can assist me with a code in VB.NET visual studio 2010 for validating Greek TAX Registration number (VAT).

like image 508
Lefteris Gkinis Avatar asked Dec 07 '10 10:12

Lefteris Gkinis


2 Answers

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.

like image 185
Hans Olsson Avatar answered Nov 15 '22 07:11

Hans Olsson


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
like image 35
Tim Schmelter Avatar answered Nov 15 '22 06:11

Tim Schmelter