all groups > visual studio .net general > february 2005 >
You're in the

visual studio .net general

group:

How To Make a Texbox Automatically Insert Hyphens When Typing SSN or Teleph. #


Re: How To Make a Texbox Automatically Insert Hyphens When Typing SSN or Teleph. # Peter van der Goes
2/5/2005 8:16:20 PM
visual studio .net general:

"clarence warren via DotNetMonster.com" <forum@DotNetMonster.com> wrote in
message news:c9a079adbc5e45e5b2e132b32f15f666@DotNetMonster.com...
[quoted text, click to view]

One way to do what you want is to use the VB Format() method. Here's a
simple example:

Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.LostFocus

Dim SSN As Integer

SSN = CInt(TextBox1.Text)

TextBox1.Text = Format(SSN, "000-00-0000")

End Sub

You can read more about Format() by searching for "Format function" in the
VB.NET help/.


--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

How To Make a Texbox Automatically Insert Hyphens When Typing SSN or Teleph. # clarence warren via DotNetMonster.com
2/5/2005 10:42:54 PM
I have been searching the internet for a week with no luck. I want to know
how to code a visual basic program so that when a user inputs a ssn or
telephone number, the dashes or hyphens automatically appears.

--
AddThis Social Bookmark Button