-
Dec 5th, 2017, 07:20 AM
#1
Thread Starter
Hyperactive Member
Force a way of writing
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
-
Dec 5th, 2017, 07:39 AM
#2
Re: Force a way of writing
For that format specifically, use a MaskedTextbox instead.
-
Dec 5th, 2017, 07:49 AM
#3
Re: Force a way of writing
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.
-
Dec 5th, 2017, 07:55 AM
#4
Thread Starter
Hyperactive Member
Re: Force a way of writing
Hiii jmcilhinney
Thanks for the help
But I'm looking for a solution away from MaskedTextBox
Cordially
MADA
-
Dec 5th, 2017, 07:58 AM
#5
Thread Starter
Hyperactive Member
Re: Force a way of writing
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
-
Dec 5th, 2017, 08:05 AM
#6
Re: Force a way of writing
So there's a tool that does exactly what you want and you want to find a way to not use it? Suit yourself.
-
Dec 5th, 2017, 08:09 AM
#7
Thread Starter
Hyperactive Member
Re: Force a way of writing
Originally Posted by jmcilhinney
So there's a tool that does exactly what you want and you want to find a way to not use it? Suit yourself.
What is this tool please ??
Cordially
MADA
-
Dec 5th, 2017, 08:11 AM
#8
Addicted Member
Re: Force a way of writing
Utterly useless, but always willing to help
As a finishing touch god created the dutch
-
Dec 5th, 2017, 08:29 AM
#9
Re: Force a way of writing
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.
This answer is wrong. You should be using TableAdapter and Dictionaries instead.
-
Dec 5th, 2017, 09:29 AM
#10
Re: Force a way of writing
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
-
Dec 5th, 2017, 11:16 AM
#11
Thread Starter
Hyperactive Member
Re: Force a way of writing
Hello every one
Maskedtextbox yes it's a great tool
But I could not settle with this method of grabbing
Cordially
MADA
-
Dec 5th, 2017, 11:20 AM
#12
Re: Force a way of writing
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
-
Dec 5th, 2017, 12:00 PM
#13
Thread Starter
Hyperactive Member
Re: Force a way of writing
Thank you for help Master Techgnome
I typed a number as an example in field Mask and after I put OK
MADA
-
Dec 5th, 2017, 05:55 PM
#14
Re: Force a way of writing
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|