954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Format contact number to (123) 456-78-95

How can I simply format the contact number in vb.net
The format that I want is

(123)456-78-95

Thank You.

aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
 

use MASK text box and set the pattern of phone number you want. you can also set ur custom format if you want...

Pgmer
Master Poster
714 posts since Apr 2008
Reputation Points: 54
Solved Threads: 121
 

there's no MASK in the properties. I think in visual basic there's one, but there's no mask in vb net 2010

aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
 

never mind, i found the solution. you have to add the MaskTextBox from the toolbox. :P

aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
 

hello aishapot !

you can use substring functions , for example you have number 1234567890

Dim p1, p2, p3, p4 As String
        If TextBox1.Text.Length = 10 Then
            p1 = TextBox1.Text.Substring(0, 3)
            p2 = TextBox1.Text.Substring(3, 3)
            p3 = TextBox1.Text.Substring(6, 2)
            p4 = TextBox1.Text.Substring(8, 2)
            TextBox1.Text = "(" & p1 & ")" & p2 & "-" & p3 & "-" & p4
        End If
waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: