void Details_FormatPhoneNo(ref TextBox TextBox) { System.Text.RegularExpressions.MatchCollection Matches = System.Text.RegularExpressions.Regex.Matches(TextBox.Text, "[0-9]"); TextBox.Text = ""; System.Text.StringBuilder Sb = new System.Text.StringBuilder(); foreach (System.Text.RegularExpressions.Match Match in Matches) { Sb.Append(Match.Value); } string Formatted = ""; Formatted = Sb.ToString(); Sb.Clear(); try { Sb.Append("(" + Do_Methods.TextFiller(Strings.Mid(Formatted, 1, 3), "0", 3) + ")"); } catch { } try { Sb.Append("-" + Do_Methods.TextFiller(Strings.Mid(Formatted, 4, 3), "0", 3) + ""); } catch { } try { Sb.Append("-" + Do_Methods.TextFiller(Strings.Mid(Formatted, 7, 4), "0", 3) + ""); } catch { } TextBox.Text = Sb.ToString(); }