Vb. NET implementation to verify credit card number _vb.net

Source: Internet
Author: User

Vb. NET code verifies that the credit card number is correct, this code uses the Luhn algorithm to verify

Dim Creditcardnumber as String
creditcardnumber = "1234567891234563" Please enter the number you want to verify by yourself
If Creditcardnumber.length < Then
  Page.ClientScript.RegisterStartupScript (Me.GetType (), "DD", "alert (' Error number only "& Creditcardnumber.length & Password"; ", True)
Else
  Dim Int
  as Integer Dim x, num, Sun as integer
  
   for x = 0
    to num = creditcardnumber.substring (x, 1)
    If (x + 1) Mod 2 <> 0 Then ' Even multiply 1 odd number by 2
      Int (x) = n UM * 2
    Else
      Int (x) = num End
    If
  Next for
  x = 0 to
    (int (x) > 9) Then
      Int (x) = ( int (x) Mod + 1 End
    If
    sun + = Int (x)
  Next
  If (Sun Mod = 0) Then
    Page.ClientScript.RegisterS Tartupscript (Me.GetType (), "ddd", "alert (' correct credit card ');", True)
  Else
    Page.ClientScript.RegisterStartupScript (Me.GetType (), "DD", "alert (' Error);", True) end
  if


  

The above mentioned is the entire content of this article, I hope to learn vb.net can help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.