Number Split

1. Member
Join Date
Dec 1969
Posts
45

## Number Split

Suppose I have one number, Say 123456789<BR>And I want to split that number in parts like-<BR>123-456-789.<BR>Which function i should use to split the number.

2. Johnny Hughes Guest

## RE: Number Split

It depends on the characteristics of the number...<BR><BR>If the number is always a fixed number of digits like your example (or for instance a SSN or Phone number), you can use a mid() function in VbScript to split it...<BR><BR>example:<BR><BR>split 111223333 into a Social Security Number format like this<BR><BR>abc=111223333<BR>abcsplit=mid(abc,1,3) & "-" & mid(abc,4,2) & "-" & mid(abc,6,4)<BR><BR>the result would be 111-22-3333<BR><BR>you can also use the left() and right() functions to do the same thing...<BR><BR>abc=111223333<BR>abcsplit=left(abc ,3) & "-" & mid(abc,4,2) & "-" & right(abc,4)<BR><BR>see devguru.com for info about these functions...<BR>http://www.devguru.com/index.asp?page=/Technologies/vbscript/quickref/mid.html

3. dinas Guest

## RE: Number Split

there is no function for it <BR>u can use a for reverse loop for i = 1 to length(string) <BR>if (i mod 3 ) is 0 then insert a - there <BR>do it in the reverse direction because some time there may be 10 <BR>charcters so one is left out <BR>

4. Member
Join Date
Dec 1969
Posts
45

## RE: Number Split

Perfect, thanx.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•