Hello VBForums
Hello eveyone
Gentelmans
Please ..
How to force to write the numbers in TextBox1 like this .. number phone:
05 87 89 25 74 23
Thank you in advance for help
Cordially
MADA
Printable View
Hello VBForums
Hello eveyone
Gentelmans
Please ..
How to force to write the numbers in TextBox1 like this .. number phone:
05 87 89 25 74 23
Thank you in advance for help
Cordially
MADA
For that format specifically, use a MaskedTextbox instead.
Lots of ways to do that. I did a Google search and found examples of formatting credit card numbers, which is a similar to what you want except you want groups of two numbers instead of four and spaces instead of dashes. Have a a try with some of those and report back if you need more help.
Hiii jmcilhinney
Thanks for the help
But I'm looking for a solution away from MaskedTextBox
Cordially
MADA
Hiii paulg4ije
Thank you gentelman
Thank you very much for the help
I will try to find a way so that the numbers in TextBox1 will be like that :
I type 0546891238 will be automatically displayed 05 46 89 12 38
Cordially
MADA
So there's a tool that does exactly what you want and you want to find a way to not use it? Suit yourself.
MaskedTextBox
JMC is pointing out MaskedTextBox is the best tool for this job.
I don't like MaskedTextBox either, but I think he's right. I am pretty sure what you are thinking is "No, there's definitely an easy way to make a normal TextBox do this". Some smart aleck always disagrees, but no one ever remembers you have to block keystrokes AND copy/paste AND programmatic text changes. It's easier to just use the control that was built for the purpose.
There's two schools of thought... 1) used a maskedTextBox ... I'm not a fan of it either, it has its issues, but for the most part, it works. 2) you don't worry about the format during entry. You just let the user type it in how they want. When the then tab out, or the textbox looses focus, THEN you re-format it how you want. This is how we do our phone numbers. We don't make any assumptions about how they are entering it - it could be local, long distance or even international, so we wait until after entry, then look at what we have, prefixes, number of digits, and then based on that and a couple of other factors, we make an attempt at formatting it. I also ran into something similar last night with my router... it was asking for a MAC Address of somehting... but didn't give a hint as to how to enter it... so I entered it with colons... when I tabbed out, it re-formatted it to all caps and no colons. same thing.
-tg
Hello every one
Maskedtextbox yes it's a great tool
But I could not settle with this method of grabbing
Cordially
MADA
I get it now... It should have been obvious but it wasn't, now I get it.
Mada can only post in haiku! Or in some haiku-like form... that explains it all now..
-tg
Thank you for help Master Techgnome
I typed a number as an example in field Mask and after I put OK
Attachment 154293
MADA
Do what you should have done in the first place and read the documentation for the MaskedTextBox.Mask property. Not surprisingly, it explains how to set a mask properly.
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx