Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:03:46+00:00 2026-05-25T00:03:46+00:00

How do I use key_down event in my vb.net? I have seen so many

  • 0

How do I use key_down event in my vb.net? I have seen so many codes on google but none of them working I don’t understand where its going wrong

  1. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx#Y600
  2. http://www.daniweb.com/software-development/vbnet/threads/114278
  3. http://forums.devshed.com/net-development-87/keypress-allow-only-letters-and-numbers-with-max-lenght-of-528176.html
  4. http://social.msdn.microsoft.com/Forums/pl-PL/Vsexpressvb/thread/aab1d64c-a9dc-4dd2-8d2f-83a414e9c909
  5. http://www.bigresource.com/VB-Lock-textbox-so-the-user-only-can-enter-numbers-a8mxDB7ouq.html
  6. http://forums.devx.com/archive/index.php/t-96951.html

Above are the links I googled and they are many links =I have googled to work on key_down events on vb.net But my god its aint working I dont know what to do.

1) How do I use textbox1_keydown event are there any necessary steps taken before using it ( why its aint workin?)

2) can anyone post a sample of these “a textbox that allows only numbers from user using key_down”

3) I see people using e.keychar but in my vb.net(2008) I dont have that keyword I guess e.keycode must be used is that right? or e.keyvalue?

4) I see e.keycode = keys.A but I need to accept ‘a’ not “A” How do I specify a number or letter with their ascii value ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:03:47+00:00Added an answer on May 25, 2026 at 12:03 am

    Are you not able to use KeyPress for some reason?

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Char.IsDigit(e.KeyChar) Then
            e.Handled = True    'Prevents all numbers from from being placed
        End If
    
        If Convert.ToInt32(e.KeyChar) = 97 Then
            e.Handled = True    'Prevents "a" from being placed
        End If
    End Sub
    

    This should do what you need. You can find a list of ASCII codes here if you don’t have one already. Take a look at the intellisense for Char. and check out all the useful things you can filter on. You can also specify exact ASCII values by converting them to int.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wonder... I mainly use .NET but now I started to investigate WINAPI
hi where to use onKey and onKeyUp/Down event in android. e.g. i have one
We use the ASP.NET profile subsystem to associate key-value pairs of information with users.
My laptop has a number pad, but it does not have a NumLock key,
I am working on a map editor for my game and I use the
Drop down list selected index event in asp.net mvc 4.0 with postback .... I
In my web app, I use the onkeydown event to capture key strokes. For
Code in question: $(#alpha).click(function(event) { event.preventDefault(); $(#show).slideToggle(); }); I have a list of files
If I have a linklabel on a .net winform, is there anyway I can,
I'm attempting to use the key up event to hijack the event and prevent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.