Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate Numeric value is displaying expected format
#1
Not Solved
My application displays the account number in specific format
(E.g :3782-924723-01008).

Can anyone suggest me how to validate that account number value is displaying in below format on my web application.

Format needs to validate : XXXX-XXXXXX-XXXXX
Reply
#2
Not Solved
use this regular expression [0-9]{4}-[0-9]{6}-[0-9]{5}
alternatively you may pass your account number to a function defined below
Code:
strAccountNumber="3782-924723-01008"

MsgBox(RegExpTest("[0-9]{4}-[0-9]{6}-[0-9]{5}", strAccountNumber))


Function RegExpTest(patrn, strng)
   Dim regEx, Match, Matches   ' Create variable.
   Set regEx = New RegExp   ' Create a regular expression.
   regEx.Pattern = patrn   ' Set pattern.
   regEx.IgnoreCase = True   ' Set case insensitivity.
   regEx.Global = True   ' Set global applicability.
   Set Matches = regEx.Execute(strng)   ' Execute search.
   For Each Match in Matches   ' Iterate Matches collection.
      RetStr = RetStr & "Match found at position "
      RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
      RetStr = RetStr & Match.Value & "'." & vbCRLF
   Next
   RegExpTest = RetStr
End Function
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to validate mandatory filed (*) in web application using balak89 1 4,109 09-13-2015, 12:54 AM
Last Post: ADITI1992
  Expected End statement error Lavanya N 2 5,155 07-27-2015, 01:52 PM
Last Post: Lavanya N
  How to check expected cookies are present or not priyanka.agarwal 0 1,966 07-02-2015, 12:43 PM
Last Post: priyanka.agarwal
Smile Need to validate a .txt file and .jpeg image. aman8604 0 2,331 04-09-2015, 11:33 AM
Last Post: aman8604
Sad Validate New Employee Creation hello_sanjay 0 1,896 04-07-2015, 06:16 PM
Last Post: hello_sanjay

Forum Jump:


Users browsing this thread: 1 Guest(s)