473,473 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Format in textbox

Hi,
How to format a textbox to force the user to write only digits like 127-343
?

Thx

Stan
Nov 20 '05 #1
11 2098
*Stan Sainte-Rose* tippselte am *20.10.2003 15:59* MESZ:
How to format a textbox to force the user to write only digits like 127-343
?


You could create two textboxes with a label between them.

Best regards,

Michael

--
Michael Kremser
http://great.dynu.com/

Nov 20 '05 #2
Thanks Michael for your quicky reply :-)
But forget the - , how to force the user to write only digits (numbers) ?

Stan


"Michael Kremser" <us****************@aon.at> a écrit dans le message de
news:ef**************@TK2MSFTNGP11.phx.gbl...
*Stan Sainte-Rose* tippselte am *20.10.2003 15:59* MESZ:
How to format a textbox to force the user to write only digits like 127-343 ?


You could create two textboxes with a label between them.

Best regards,

Michael

--
Michael Kremser
http://great.dynu.com/

Nov 20 '05 #3
http://www.a1vbcode.com/app.asp?ID=2395
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
Thanks Michael for your quicky reply :-)
But forget the - , how to force the user to write only digits (numbers) ?

Stan


"Michael Kremser" <us****************@aon.at> a écrit dans le message de
news:ef**************@TK2MSFTNGP11.phx.gbl...
*Stan Sainte-Rose* tippselte am *20.10.2003 15:59* MESZ:
How to format a textbox to force the user to write only digits like 127-343 ?


You could create two textboxes with a label between them.

Best regards,

Michael

--
Michael Kremser
http://great.dynu.com/


Nov 20 '05 #4
Or you could use a regular expression which will increase
performance than adding another text box.
--------------------------------------------

Dim objRegExpr

'Create an instance of the regexp object
Set objRegExpr = New regexp

objRegExpr.Pattern = "\[0-5]{3}-[0-5]{3}"

Nov 20 '05 #5
*scorpion53061* tippselte am *20.10.2003 16:19* MESZ:
Case 48 To 57, 8, 13 ^^ ^^ ^ ^^
Case 45 ^^
Case 46

^^

Good control, but _NEVER_ use magic numbers!!! This is a very bad
practice. Instead, define constants or use the one from the .net
Framework, like
--
Michael Kremser
http://great.dynu.com/

Nov 20 '05 #6
*scorpion53061* tippselte am *20.10.2003 16:19* MESZ:
Case 48 To 57, 8, 13
^^ ^^ ^ ^^
Case 45
^^
Case 46


^^

Good control, but _NEVER_ use magic numbers!!! This is a very bad
practice. Instead, define constants or use the one from the .net
Framework, like

Keys.D0 for 48
Keys.Back for 8

etc.

Best regards,

Michael

--
Michael Kremser
http://great.dynu.com/

Nov 20 '05 #7
you can test the vanue of the text on the leave event of the textbox using
string functions
ex
select case true
case t.text.length = 7
t.focus
case not t.text.indexof("-"c) = 3
t.focus
case not isnumeric(t.substring(0,3))
case not isnumeric(t.substring(4,3))

.....

if the test is no to your liking display a messagebox, statusbar message ...
and put them back in the txt until they jump to your commands ;p
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Hi,
How to format a textbox to force the user to write only digits like 127-343 ?

Thx

Stan

Nov 20 '05 #8
ps you can make it a bit easyer for them:
if the input is 6 long and numeric then add the - yourself :)
"EricJ" <ericRéMo**@ThiSomnipack.be> wrote in message
news:3f*********************@reader1.news.skynet.b e...
you can test the vanue of the text on the leave event of the textbox using
string functions
ex
select case true
case t.text.length = 7
t.focus
case not t.text.indexof("-"c) = 3
t.focus
case not isnumeric(t.substring(0,3))
case not isnumeric(t.substring(4,3))

....

if the test is no to your liking display a messagebox, statusbar message .... and put them back in the txt until they jump to your commands ;p
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Hi,
How to format a textbox to force the user to write only digits like

127-343
?

Thx

Stan


Nov 20 '05 #9
Thanks everybody for your contributions...

Stan

"EricJ" <ericRéMo**@ThiSomnipack.be> a écrit dans le message de
news:3f*********************@reader1.news.skynet.b e...
you can test the vanue of the text on the leave event of the textbox using
string functions
ex
select case true
case t.text.length = 7
t.focus
case not t.text.indexof("-"c) = 3
t.focus
case not isnumeric(t.substring(0,3))
case not isnumeric(t.substring(4,3))

....

if the test is no to your liking display a messagebox, statusbar message .... and put them back in the txt until they jump to your commands ;p
"Stan Sainte-Rose" <st**@cyber972.com> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Hi,
How to format a textbox to force the user to write only digits like

127-343
?

Thx

Stan


Nov 20 '05 #10
* "Stan Sainte-Rose" <st**@cyber972.com> scripsit:
How to format a textbox to force the user to write only digits like 127-343


<http://www.thecodeproject.com/vb/net/CpFlexMaskEditBox.asp>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #11
On Mon, 20 Oct 2003 09:59:12 -0400, Stan Sainte-Rose wrote:
Hi,
How to format a textbox to force the user to write only digits like 127-343
?

Thx

Stan


If you download the VB Resource Kit for .Net from Microsoft, that comes
with Component One studio which includes a masked edit box.
--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Patrick J. Schouten | last post by:
I am new to ASP/VBScript and I am trying to format a texbox when a user exits it. In Visual Basic you could put the following in the Exit property of the textbox: textbox1 = Format(textbox1,...
3
by: H Branyan | last post by:
I need to format a textbox value a user enters. The user will enter 13 characters, and then I have to format them, preferably in the onBlur event, to look like this: XXXX-XX-XXX-XXXX I found...
0
by: Ryan Joseph So | last post by:
Hi, I made a custom textbox control inheriting from native windows textbox. The i made another form where i used the custom control, what i want to do is to bind the data from my datatable to...
1
by: nic | last post by:
Hi, I have a textbox value that I need to force (and format) to be a numeric value. For example, I want to allow a user to type 1000 or 1,000 or 1,000,000 but not something that is not numberic....
4
by: Art | last post by:
Hi, I have a MyTextBox class that inherits from TextBox. How do I make it display the information as, say 0.00. Sometimes the value will be typed by the user. Other times the value will be...
15
by: staeri | last post by:
I'm looping through some textboxes to sum the values. If the value in the textbox has a dot or a space as thousand separator the sum function doesn't work. Can someone help me to make it work...
0
by: Ivan Jericevich | last post by:
I want to format a Textbox in VB Express 2005 to decimal places, where "Oh" where do I find the Format Property
3
by: Ronald S. Cook | last post by:
Stupid q for the day, but if the user enters 2 in a textbox, I want to display as 2.00. If they enter 2.129 I want it as 2.13. I'm guessing will code in the validated method of the textbox,...
3
by: engteng | last post by:
How do I format the textbox to 3 decimal point all the time? Regards, Tee
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
I come from an Access background. In Access I was able to format certain types of data such as SSN, Date, Phone Number, etc. with the special characters during data-entry and display, but the...
0
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...
0
jinu1996
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.