473,749 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7868

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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MaskedTextBox1. TextChanged
Dim allowedchars As String = "1234567890abcd efABCDEF"
Dim i As Integer = 0
For i = 0 To MaskedTextBox1. Text.Length - 1
If Not allowedchars.In dexOf(MaskedTex tBox1.Text.Subs tring(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...@discu ssions.microsof t.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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MaskedTextBox1. TextChanged
Dim allowedchars As String = "1234567890abcd efABCDEF"
Dim i As Integer = 0
For i = 0 To MaskedTextBox1. Text.Length - 1
If Not allowedchars.In dexOf(MaskedTex tBox1.Text.Subs tring(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.KeyEventA rgs) Handles txtKey.KeyDown
e.SuppressKeyPr ess = Not ((e.KeyCode >= Windows.Forms.K eys.A And
e.KeyCode <= Windows.Forms.K eys.F) _
Or (e.KeyCode >= Windows.Forms.K eys.NumPad0 And e.KeyCode <=
Windows.Forms.K eys.NumPad9) _
Or (e.KeyCode >= Windows.Forms.K eys.D0 And e.KeyCode <=
Windows.Forms.K eys.D9) _
Or e.KeyCode = Windows.Forms.K eys.Left Or e.KeyCode =
Windows.Forms.K eys.Right)
End Sub

and shortcuts of course disabled

Mex
"Meelis Lilbok" <me***********@ deltmar.eewrote in message
news:uk******** ******@TK2MSFTN GP02.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
875
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
2558
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 type one number. So you have to hit <backspace>. How do I make it so clicking into this box puts your cursor all the way to the left side? Also, I can't get the box to accept the range "-1" thru "99". How can that be done? ..NET 2.0 of...
0
459
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 is 75000. In the textbox it displays 750,00 What am I doing wrong?? ------------------------------------------------------------------------------------ Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's Resource site.
3
3757
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 name as string
2
1524
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
1754
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 numbers properly, hence the mask. What I cannot seem to figure out is why can I not send the button captions (captions are the value of the number buttons, 1 through 9) into the masked box without an error? I get: Run Time Error '380'. Invalid...
0
1169
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
2375
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 the decimal point and expand to the left as I input the currency amount, until I enter a decimal point, following which the cursor would move to the first position to the right of the decimal point. Is this possible and, if so, how would i go...
3
5477
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
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
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 we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.