I have textbox1 that takes a phone number xxx-xxx-xxxx. Is it possible
to have it start off looking like - - and when someone types the
number fill in around the -s?
If not how about after they type the 3rd number have the - fill in
automatically etc.
Lastly if that isn't doable then where is the best place to put code to
reformat the number after they are finished entering it. Perhaps
textbox1_leave doesn't appear to work? 6 2616
I got textbox1_leave working. I'd still like answers to my first two
options if anyone knows how.
cj wrote: I have textbox1 that takes a phone number xxx-xxx-xxxx. Is it possible to have it start off looking like - - and when someone types the number fill in around the -s?
If not how about after they type the 3rd number have the - fill in automatically etc.
Lastly if that isn't doable then where is the best place to put code to reformat the number after they are finished entering it. Perhaps textbox1_leave doesn't appear to work?
cj,
I cannot remember who is using VS2005 and who is using VS2003. However in
version 2005 is the masked texbox, wich is of course created as a need. http://msdn2.microsoft.com/en-us/lib...edtextbox.aspx
Cor
"cj" <cj@nospam.nospam> schreef in bericht
news:uW**************@TK2MSFTNGP05.phx.gbl... I have textbox1 that takes a phone number xxx-xxx-xxxx. Is it possible to have it start off looking like - - and when someone types the number fill in around the -s?
If not how about after they type the 3rd number have the - fill in automatically etc.
Lastly if that isn't doable then where is the best place to put code to reformat the number after they are finished entering it. Perhaps textbox1_leave doesn't appear to work?
Hi,
Just as MVP Cor suggested, in Visual Studio 2005 you can use the
MaskedEditBox--just set its Mask as 000-000-000.
If you work with VS.NET 2003, I think you can set the textbox's default
text as "000-000-000", then handle that textbox's event as follows:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar > "9" Or e.KeyChar < "0" Then
e.Handled = True
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text.Length = 3 Then
TextBox1.Text += "-"
TextBox1.Select(TextBox1.Text.Length, 0)
End If
If TextBox1.Text.Length = 7 Then
TextBox1.Text += "-"
TextBox1.Select(TextBox1.Text.Length, 0)
End If
End Sub
By the way, in the textbox's TextChanged event handler, you also need to
check and modify the string if the user paste stuff to it.
Thanks!
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
thanks--still 2003 for now but hoping to move to 2005 soon.
Cor Ligthert [MVP] wrote: cj,
I cannot remember who is using VS2005 and who is using VS2003. However in version 2005 is the masked texbox, wich is of course created as a need.
http://msdn2.microsoft.com/en-us/lib...edtextbox.aspx
Cor
"cj" <cj@nospam.nospam> schreef in bericht news:uW**************@TK2MSFTNGP05.phx.gbl... I have textbox1 that takes a phone number xxx-xxx-xxxx. Is it possible to have it start off looking like - - and when someone types the number fill in around the -s?
If not how about after they type the 3rd number have the - fill in automatically etc.
Lastly if that isn't doable then where is the best place to put code to reformat the number after they are finished entering it. Perhaps textbox1_leave doesn't appear to work?
thanks
Gary Chang[MSFT] wrote: Hi,
Just as MVP Cor suggested, in Visual Studio 2005 you can use the MaskedEditBox--just set its Mask as 000-000-000.
If you work with VS.NET 2003, I think you can set the textbox's default text as "000-000-000", then handle that textbox's event as follows:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar > "9" Or e.KeyChar < "0" Then e.Handled = True End If End Sub
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text.Length = 3 Then TextBox1.Text += "-" TextBox1.Select(TextBox1.Text.Length, 0) End If
If TextBox1.Text.Length = 7 Then TextBox1.Text += "-" TextBox1.Select(TextBox1.Text.Length, 0) End If End Sub
By the way, in the textbox's TextChanged event handler, you also need to check and modify the string if the user paste stuff to it.
Thanks!
Best regards,
Gary Chang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
You are welcome!
Good Luck!
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Deborah V. Gardner |
last post by:
I would like to use conditional formatting on a subform and have 2
textbox affected.
ItemID Qty Cost OrderDate
123 1 10.00 3/3/05
345 ...
|
by: GGerard |
last post by:
Hello
Is there a way to use a variable in the Conditional Formatting of a Textbox?
Example :
I want the background of a textbox in a continuous form to change color when
the value of...
|
by: BBFrost |
last post by:
I'm receiving decimal values from database queries and placing them on a
report page.
The users want to see the following ....
Db Value Display Value
123.3400 123.34...
|
by: Duppypog |
last post by:
I want the contents of a textbox to be ALL CAPS when added to the database.
How do I do that?
And on the flip side - if I have existing data, what's the data formatting
expression for ALL CAPS...
|
by: pallabs |
last post by:
I'm new to asp.net and is having problems doing the following:
1. The tab sequence in a asp form is not working properly. The page is
a login form and tabindex is set to 0 for username, 1 for...
|
by: Mike P |
last post by:
The default format for the DetailsView control is for there to be a row
per field. Is it possible set it to show more than one column per row
(see below)?
ID ... Name ......
|
by: Peter Newman |
last post by:
the data input app im writing has some 30 + input fields and i want to be
able to format them.
I know i can use the .validate on each textbox and format the 'string'
however this require loads...
|
by: robertng90025 |
last post by:
I'm having a problem with MS Access 2003 and its conditional
formatting.
I have textboxes on a continuous form whose left and right margins are
set to 0.03 inches. Based on each textbox's...
|
by: Greg (codepug |
last post by:
Access 2000
Using a textbox of a single form, I created a calculated field. The
following code is in the Control Source for this field:
=IIf(=24,+(/),/
)
The numbers that are calculated are...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |