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

(123)456-78-95

Thank You.

Recommended Answers

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

Jump to Post

All 4 Replies

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

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

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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.