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

  • Thread starter Thread starter pcserver
  • Start date Start date
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
 
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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top