Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Validating a VAT number

Validating a VAT number

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mcm
    wrote on last edited by
    #1

    ElseIf txtVAT.Text <> " & IE#######% & " Then MsgBox "Please enter a valid VAT Number starting with IE ", vbExclamation, "Invalid Data" Exit Sub the above is the code i use to ensure a VAT number is entered in correctly (ie an example of a correct VAT number is IE5314569A), however, it throws the message box regardless. What would be the correct syntax? Any help would be greatly appreciated!

    H A 2 Replies Last reply
    0
    • M mcm

      ElseIf txtVAT.Text <> " & IE#######% & " Then MsgBox "Please enter a valid VAT Number starting with IE ", vbExclamation, "Invalid Data" Exit Sub the above is the code i use to ensure a VAT number is entered in correctly (ie an example of a correct VAT number is IE5314569A), however, it throws the message box regardless. What would be the correct syntax? Any help would be greatly appreciated!

      H Offline
      H Offline
      Hesham Amin
      wrote on last edited by
      #2

      Hi.. Why don't use MaskEdit control ? anyway .. to compare strings use strComp function.

      1 Reply Last reply
      0
      • M mcm

        ElseIf txtVAT.Text <> " & IE#######% & " Then MsgBox "Please enter a valid VAT Number starting with IE ", vbExclamation, "Invalid Data" Exit Sub the above is the code i use to ensure a VAT number is entered in correctly (ie an example of a correct VAT number is IE5314569A), however, it throws the message box regardless. What would be the correct syntax? Any help would be greatly appreciated!

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        First, VB doesn't use wild cards comparing strings. It also doesn't do regular expressions natively. You could use a third party regular expression control like the Regular Expression Library (http://download.com.com/3000-2070-5588590.html?tag=lst-4-10) to validate the input. The other option would be to build another string by scanning the input string and replacing each number with a # character and each letter with a % character. Then your code snippet would work.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups