This is the code I used to create a webform that verifies the validity of a Visa credit card.
   Private Sub uiVerifyButton_Click(ByVal sender As System.Object, ByVal e _
        As System.EventArgs) Handles uiVerifyButton.Click
        Dim possibleNum(), ccStr As String
        ccStr = Me.uiCreditTextBox.Text.Replace(" ", "")
        Dim nDigits, mySum As Integer
        nDigits = Len(ccStr)
        ReDim possibleNum(nDigits) 
     
         If (nDigits <> 16 AndAlso nDigits <> 13) Then
            View HTML source code to see what goes here.
         Else
             mySum = myLuhn(possibleNum, ccStr, nDigits)

             If (mySum Mod 10 = 0) Then
                 Me.uiValidLabel.Text = "Valid Number"
             Else
                 Me.uiValidLabel.Text = "Invalid Number"
             End If
         End If
    End Sub

    Private Function myLuhn(ByRef possNum() As String, ByRef ccStrg As String _
            , ByVal nDigits As Integer) As Integer
        Dim sum, parity, digit, i As Integer
        parity = nDigits Mod 2
        For i = 0 To nDigits - 1
            possNum(i) = ccStrg.Substring(i, 1)
            digit = CInt(possNum(i))
            If (i Mod 2 = parity) Then
                digit *= 2
            End If
            If (digit > 9) Then
                digit -= 9
            End If
            sum += digit
        Next i
        Me.uiValidLabel.Visible = True
        Return sum
    End Function