473,320 Members | 2,097 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,320 software developers and data experts.

Masked TextBox

Hi

Is it possible set mask in masked textbox for selected chars only?
For example numbers 0-9 and letters A-F (hex. chars only)
Best Regards;
Mex
May 24 '07 #1
3 7843

not sure if you can do it as part of the mask itself, but obviously you
could do something like the follwing in the TextChanged event...

Private Sub CheckIfHex(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MaskedTextBox1.TextChanged
Dim allowedchars As String = "1234567890abcdefABCDEF"
Dim i As Integer = 0
For i = 0 To MaskedTextBox1.Text.Length - 1
If Not allowedchars.IndexOf(MaskedTextBox1.Text.Substring (i, 1))
0 Then
MsgBox("Not a valid hex character")
End If
Next
End Sub

James


"Meelis Lilbok" wrote:
Hi

Is it possible set mask in masked textbox for selected chars only?
For example numbers 0-9 and letters A-F (hex. chars only)
Best Regards;
Mex
May 24 '07 #2
On May 24, 5:52 am, jamesb24 <james...@discussions.microsoft.com>
wrote:
not sure if you can do it as part of the mask itself, but obviously you
could do something like the follwing in the TextChanged event...

Private Sub CheckIfHex(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MaskedTextBox1.TextChanged
Dim allowedchars As String = "1234567890abcdefABCDEF"
Dim i As Integer = 0
For i = 0 To MaskedTextBox1.Text.Length - 1
If Not allowedchars.IndexOf(MaskedTextBox1.Text.Substring (i, 1))0 Then

MsgBox("Not a valid hex character")
End If
Next
End Sub

James

"Meelis Lilbok" wrote:
Hi
Is it possible set mask in masked textbox for selected chars only?
For example numbers 0-9 and letters A-F (hex. chars only)
Best Regards;
Mex
I would prefer using the keypress or keydown event for the textbox and
stop any non-hex digits there. Then you would just have to stop the
user from pasting in the inappropriate characters (you could override
WndProc and kill the WM_PASTE message).

Let me know if you need some sample code.

Thanks,

Seth Rowe

May 24 '07 #3
i did so

Private Sub txtKey_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtKey.KeyDown
e.SuppressKeyPress = Not ((e.KeyCode >= Windows.Forms.Keys.A And
e.KeyCode <= Windows.Forms.Keys.F) _
Or (e.KeyCode >= Windows.Forms.Keys.NumPad0 And e.KeyCode <=
Windows.Forms.Keys.NumPad9) _
Or (e.KeyCode >= Windows.Forms.Keys.D0 And e.KeyCode <=
Windows.Forms.Keys.D9) _
Or e.KeyCode = Windows.Forms.Keys.Left Or e.KeyCode =
Windows.Forms.Keys.Right)
End Sub

and shortcuts of course disabled

Mex
"Meelis Lilbok" <me***********@deltmar.eewrote in message
news:uk**************@TK2MSFTNGP02.phx.gbl...
Hi

Is it possible set mask in masked textbox for selected chars only?
For example numbers 0-9 and letters A-F (hex. chars only)
Best Regards;
Mex

May 24 '07 #4

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

Similar topics

0
by: cichy | last post by:
i spend a lot of time on looking for a masked textbox component... where i can find a free one for vc++ .net 2003 ? i found one but written in c# :o(( best regards marcin.
2
by: Brett Romero | last post by:
I have a masked textbox that excepts values of 0 thru 99. The mask is 00. Tabbing into this box is fine but if you click into it, you are one space over from the left. This means you can only...
0
by: james.czebiniak | last post by:
newbie to .net I have a masked textbox intended to display/input salary. The mask is 999,999 or ###,###. When I place the info from the database into the field it formats incorrectly. The salary...
3
by: gayano | last post by:
Hi, I'm using Visual studio 2005 pro Ver..]]] I have a Form named form1 textbox named txtName masked textbox (Date Masked) named txtMaskedDate and a button to add data named btnAdd dim...
2
by: steve waugh | last post by:
Hi I want to use Masked TextBox Control in my ASP.NEt application. The same is used in C# on Window Appliation but i want to use in my Web Application, is there any way out Thx
0
by: michels287 | last post by:
I have a masked textbox on my form. I have an onscreen keyboard with numbers only. The masked format for the masked textbox is: (###) ### - #### I want to make sure they enter the phone...
0
by: JoeP | last post by:
Hi All, How can you manage to have money with a dollar sign in a masked textbox? I tried enter this one in the mask propert as: $999,999.99 but it does not work for me. Any idea? Thanks,
0
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I have a masked textbox with following mask: #####.## with a Validating Type of decimal. (It's a currency input field) I would like the cursor to position itself in the first spot to the left of...
3
by: buddyr | last post by:
Hello, I have a texbox with error provider control: if(textbox.text.length <=0) { errorprovider1.seterror(textbox,"enter part number"); } else { errorprovider1.seterror(textbox, "");
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
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.