-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Rambabu Kodali
Message 3 in Discussion
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
TextBox1.Text = "( ) - "
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
With e
'Valid keys are 0-9 & backspace, or a final length of 14
If Not ((Asc(.KeyChar) >= 48 And Asc(.KeyChar) <= 57) Or _
Asc(.KeyChar) = 8) Or _
Len(sender.Text.Replace(" ", "")) >= 13 Then 'this also replaces the
" " between the Area Code and the Exchange "(999) 999-9999", hence a length of
13 here
.Handled = True 'Throw away the key stroke
Exit Sub
End If
End With
Dim idx As Integer
idx = TextBox1.Text.IndexOf(" ") 'Find the first available position to
insert the entered digit
If idx >= 5 Then
idx = TextBox1.Text.IndexOf(" ", 6) 'adjust for the space between the
Area Code and the Exchange
End If
Dim str As String
With TextBox1
str = .Text.Substring(0, idx)
str += CStr(Microsoft.VisualBasic.Val(e.KeyChar))
str += .Text.Substring(str.Length, .TextLength - (idx + 1))
End With
TextBox1.Text = str 'Set the textbox to the built string
e.Handled = True 'Throw away the keystroke since we manually placed it in
the TextBox
End Sub
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]