473,503 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable keys in program

284 Contributor
I am using VB6.
I want that in my whole program the user can only enter data as numbers (0-9), alphabetical (a-z) and . (dot/point).
How can I disable all the other keys?

I know the code how to permit the keys in the keypress event of any textbox
by using this code:

Expand|Select|Wrap|Line Numbers
  1. Dim comp As Boolean
  2. comp = Chr(KeyAscii) Like "[1-9.0]"
  3. If Chr(KeyAscii) = vbBack Then Exit Sub
  4. If comp = False Then
  5.   KeyAscii = 0
  6. End If
Now instead of writing it to all the text boxes (which are huge in number) I want to disable the other keys in start module.
How to do this?
Dec 20 '07 #1
4 1922
debasisdas
8,127 Recognized Expert Expert
Instead of writing all that to the keypress event of all the individual textboxes ,write that in the keypress event of the form and make the KeyPreview property of the form to true.
Dec 20 '07 #2
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

You cannot write for the whole project. Instead you can write for each form.
Create it as a general procedure in a .bas module.
Make Form's property : KeyPreview =True
and in Form's KeyPress Event, call that procedure by passing KeyAscii.

Regards
Veena
Dec 20 '07 #3
muddasirmunir
284 Contributor
Thanks for nice suggestion


Hi,

you cannot write for the whole project. Instead you can write for each form.
Create it as a General Procedure in .bas module..
Make Form's property : KeyPreview =True
and in Form's KeyPress Event, call that procedure by passing KeyAscii

REgards
Veena
Dec 20 '07 #4
Ali Rizwan
925 Contributor
Use modules for writing the code single time for entire project.

Regards

>> ALI <<
Dec 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5748
by: Dw70 | last post by:
I need write simple program with work in background and have only one function when it is run F1 I disable and when I pres for example ctrl+k it (program is terminate) maybe somebody have...
3
43925
by: Stefan | last post by:
Hy, i have an app and i must disable this combination: ALT+F4; CTRL+ALT+DEL; CTRL+ESC;ALT+TAB like this: i find something on Internet and i can block ALT+F4 protected override...
4
3544
by: | last post by:
I want to program a application for user login in windows.Now I has some question about disable the system hotkey(c+a+d,alt+tab,win key.etc.) and limit the mouse cursor in winform How can I do it?...
1
2916
by: Geroge D. Lake | last post by:
Hi, I need to disable the resizing of a datagrid. I have tried al day and no luck. Any Ideas? Thanks. George.
1
1921
by: johnb41 | last post by:
I have a datagrid that successfully allows editing and updating (with dataadapter.update command). I want the user to be able to edit the "text" in the datagrid, but i DON'T want the user to be...
16
6229
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
3
2585
by: voroojak | last post by:
hi I have a such abig problem. i have to disable the shortcut keys (table, query, report, .....) except form. the user should just be able to open form and all other the shortcut should be disable....
7
2274
by: =?Utf-8?B?U3VuZGFy?= | last post by:
Hello ALL, I want some help on How to Disable the Combination Keys stokes like ALT+CTRL+DEL, ALT+TAB or any other Combination using C#. Hope for your response. -- Best Regards,
16
6630
by: nagmvs | last post by:
Hi, Can any one tell me How to disable Keyboard Functions using JavaScript.If knows please tell me the code.Also tell me the code for mouse disable also. Thanks, Nagesh.
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7462
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...
0
5578
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,...
0
4673
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...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
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...

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.