473,322 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to set the TextBox digital only?

Hi, men.
It's just a small problem. On previous VB, I can reset the keycode in the
KeyDown or KeyUp event. But in VB.NET, The property of parameter "e" is
readonly. How can I have a TextBox just only could be imputed digital.
Without any letter.

Thx

Jan 15 '06 #1
4 2405

"Steven.Xu" <St******@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
It's just a small problem. On previous VB, I can reset the keycode in the
KeyDown or KeyUp event. But in VB.NET, The property of parameter "e" is
readonly. How can I have a TextBox just only could be imputed digital.
Without any letter.


Digits (0-9) and no leters (a-z) ?

Masked Edit Control ?

Jan 15 '06 #2
There should be a better way to do this, but since I haven't looked I can
tell you about two ways that can work for you.

1. Use SendKeys with an Ignore flag
I expect you are trying to change the keys inputted to some other value.
Well when the user presses a key, set a Flag like IgnoreKey and then use
sendkeys to use the corrected input to the textbox, only this time IgnoreKey
will not process the keystroke and pass it as-is to the textbox. Then you
can set IgnoreKey back to false.

Whew... I hope you got what I tried to explain.

2. Modify the SelText property directly.
Modifying the Text property is one memory intensive momma, so use the
seltext property instead... Put some code like this in your keydown event.

myTextbox.Seltext = mykeychar

hmm....

Personally I really loved it when we could simply modify the KeyCode, I
built a nice little app which sold a few thousand copies using just that
functionality. :)

Regards
Cyril Gupta
Jan 15 '06 #3
This is definitely an easier way to do it... I misunderstood your question a
bit. I didn't quite understand what you meant by digital input and thought
you needed added functionality like changing the keystroke values.

Definitely recommend the Masked Edit Control. It's included in VS2005.

Regards
Cyril Gupta
Jan 15 '06 #4
"Steven.Xu" <St******@discussions.microsoft.com> schrieb:
It's just a small problem. On previous VB, I can reset the keycode in the
KeyDown or KeyUp event. But in VB.NET, The property of parameter "e" is
readonly. How can I have a TextBox just only could be imputed digital.


\\\
Imports System.ComponentModel.Component
Imports System.Text.RegularExpressions
..
..
..
Private Sub TextBox1_Validating( _
ByVal sender As Object, _
ByVal e As CancelEventArgs _
) Handles TextBox1.Validating
Dim SourceControl As TextBox = DirectCast(sender, TextBox)
Dim ErrorText As String
If Not Regex.IsMatch(SourceControl.Text, "^\d*$") Then
ErrorText = "Value must consist of decimal digits."
End If
Me.ErrorProvider1.SetError( _
SourceControl, _
ErrorText _
)
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jan 15 '06 #5

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

Similar topics

7
by: Guangxi Wu | last post by:
Hi all, Happy New Year. I am using SignedXML and an X509 certificate to digitally sign a SOAP message body and put the signature in the SOAP header for a B2B business application. Can you...
5
by: John Campbell | last post by:
Hi everyone I've been doing my best to understand the specifics of implimentating XML Digital Signatures, but I seem to be missing a fundamental concept. Let me start with a description of the...
2
by: Martin Høst Normark | last post by:
Hi everyone Has anyone got the least experience in integrating the Digital Signature with an ASP.NET Web Application? Here in Denmark, as I supose in many other countries, they're promoting...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
8
by: HalcyonWild | last post by:
Hi, I installed the free version(command line only) of the digital mars c++ compiler. It said it features a garbage collection mechanism, but there was no documentation. I figured out that...
1
by: cassey14 | last post by:
Hi Sir, Im just new in programming using javascript and php.Please help me. I have a problem here..Im doing a system using php and its important to have date and digital time inside a textbox...
10
by: Henrik Dahl | last post by:
Hello! I have some images (for instance in .jpg files) which I would like to apply digital rights management for, i.e. that only authorized users may wiew then using their www browser, i.e. if a...
1
by: gdgass | last post by:
Hi, I'm in the process of developing an app to scan and archive photos based upon the EXIF/Photo Keyword property. One of the requirements is that the Photo's keywords be editable via Digital...
5
by: troy_lee | last post by:
We have an application developed by one developer. He compiled the database into an application and digitally signed the application. He doesn't know if he used selfcert of makecert to make the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.