UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Closed TopicStart new topic
> Uk Vat Validator Asp - Vbscript    
 
   
ihitman
post Jan 30 2004, 07:10 AM
Post#1


VIP Emeritus
Posts: 2,103
Joined: 1-February 01
From: North East, England


Small function here to return whether a VAT number is correct or incorrect.
!--c1-->
CODE
<%
Function fVat(Vat)
  'fVAt Function for ASP
  'Works out whether a VAT number is a valid one or not
  'By Rob Boyle, 2004
  Dim nSingle(6), i, h, Total, Checksum
  'Get VAT checksum
  Checksum = Right(Vat, 2)
  'Place each number into integer array
  For i = 0 To 6
    nSingle(i) = Right(Left(Vat, i + 1), 1)
  Next
  'Calculate total of individual numbers
  h = 0
  For i = 8 To 2 Step -1
    Total = Total + nSingle(h) * i
    h = h + 1
  Next
  'Loop to get negative number
  Do Until Total < 0
    Total = Total - 97
  Loop
  'Minus negative with vat checksum
  If Not(Total+Checksum) Then
    fVat = true
  Else
    fVat = false
  End If
End Function
%>

Enjoy,
ih.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd January 2018 - 07:05 PM