473,379 Members | 1,520 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,379 software developers and data experts.

How to check whether the text in a textbox is a hex?Thanks

If i want to limit the users to input only 0-9 and A-F/a-f, how can i do
it?thanks
Nov 16 '05 #1
3 2669
I put the following in the KeyPress event of the text box. I would however
define temp somewhere out side the event.

string temp = "012345679abcdefABCDEF";

if (temp.IndexOf(e.KeyChar) == -1)

{

e.Handled = true;

}
--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"pcserver" <te**@temp.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
If i want to limit the users to input only 0-9 and A-F/a-f, how can i do
it?thanks

Nov 16 '05 #2
you can use Regex function

// Function to Check for AlphaNumeric.
public bool IsAlphaNumeric(String strToCheck)
{
Regex objAlphaNumericPattern=new Regex("[^a-zA-Z0-9]");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
--
rajagopal

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Thanks
Nov 16 '05 #4

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

Similar topics

5
by: Yuelin | last post by:
Hi there What's the best way of checking whether a textbox is empty? Thanks. Yuelin
2
by: MikeY | last post by:
Hi all, I am coding window forms in C#. My problem is this: I have created a "Check ListView" or a 'ListView' with checkbox's. I have populated the it with my files from my folders, mps, txt,...
2
by: Yoshitha | last post by:
In my webform i have 2 textbox controls and one button control. in 1st textbox control i'll enter email id when it lost its focus i've tocheck whether the entered email id exist in...
2
by: buran | last post by:
Dear ASP.NET Programmers, I have a question about a script I'm trying to code and invoke when a button (btnSave) is pressed on the page. This script should only run when a textbox (txtAD) on the...
8
by: Sandy | last post by:
Hello - This code was snagged by me from the Internet and altered. Its purpose is to check for swear words. It works the way it currently is, but I need it to be more generic -- i.e., I don't...
4
by: Craig G | last post by:
i have a small routine which i used in VB6 to check whether or not a field is off numeric input but im having a problem when trying to change this over to .NET what do i use instead of KeyAscii...
4
by: Brett Romero | last post by:
Besides using a very long if statement and storing old text box values, is there a way to see if text box values have changed since an event? For example, say I have 8 textboxes when the form...
0
by: Jay Kudecha | last post by:
Hi All, I am preparing a .Net deployment project, where i need to get some data from the user. I have added custom textbox dialog in Installer which has one textbox visible where the user has to...
2
by: sweatha | last post by:
Hi friends This is Sweatha. My problem is, I have created the Registration Form with one LabelBox as Label1 one TextBox as TextBox1 & one Button as Button1. Then I have generated the random...
2
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
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...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.