473,659 Members | 3,348 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 1928
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
5763
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 similar program or part of code I don't know how get signal F1 pressing and neutralize it?
3
43989
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 System.Boolean ProcessCmdKey(ref System.Windows.Forms.Message msg,System.Windows.Forms.Keys keyData)
4
3567
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? thanks!
1
2923
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
1936
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 able to DELETE rows. The OleDbCommandBuilder automatically creates the DELETE SQL statement. Is there any way I can disable it? If not, what approach should I be using? Thanks!
16
6258
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
2591
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. i have one more problem and that is i want to disable my total field. i eman teh user cant enter any data in total fields. my total field is working under save buttom. i mean when i press teh save buttom it will calculate the total. it is working...
7
2288
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
6656
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
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
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
8627
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
7356
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
5649
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
4175
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...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.