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

VB.Net Key Press

Hi,
How can we use the down and up keys in vb.net using Keypress?Any one can help me? Pls.
Jun 9 '07 #1
5 34216
kenobewan
4,871 Expert 4TB
Welcome to TSDN. I suggest using KeyCode values in the KeyUp (or KeyDown) event, i.e. keypress won't work. HTH.
Jun 9 '07 #2
Hi,
How can we use the down and up keys in vb.net using Keypress?Any one can help me? Pls.

The KeyPress event is not missing. If you want to get the ASCII code of the key pressed in the KeyPress event, use the KeyPressEventArgs' KeyChar property to get the Char representing the key pressed, and then convert it to an ASCII keycode using AscW. Also, if you want to determine whether a Char is numeric or alphabetic, you can use the IsNumber and IsLetter shared methods of Char. For example:
Code:

Private Sub frmGame_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles MyBase.KeyPress
Dim keyascii As Integer = AscW(e.KeyChar)
Dim bNumber As Boolean = Char.IsNumber(e.KeyChar)
Dim bLetter As Boolean = Char.IsLetter(e.KeyChar)
End Sub
Jun 9 '07 #3
Welcome to TSDN. I suggest using KeyCode values in the KeyUp (or KeyDown) event, i.e. keypress won't work. HTH.

Thank You For your Suggestion.It is very useful to me.
Jun 11 '07 #4
but how to organize another scenario?

1. you have a loop in
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

2. pressing a key you have to jump in
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

3. and go back to
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dec 29 '07 #5
CyberSoftHari
487 Expert 256MB
Call the Form1_KeyPress in Form1_Paint.
Note: better generate a method and call anywhere. Event should call only on event activated.
Dec 29 '07 #6

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

Similar topics

1
by: asdasd | last post by:
Hello there, I'm hoping someone might be able to help me out. Its been awhile since I've programmed in visual basic (and roughly at that)... I want to create a program that will allow me to...
1
by: Brian Basquille | last post by:
Can i carry out a command during execution with the press of a key? Am working on a Countdown Timer and everytime i press p on the keyboard, i want to add a minute to the timer and every time i...
3
by: John Howard | last post by:
I'm trying to write a simple press any key routine, but am having some problems. Here is the routine: void PressAnyKey () { cout << "Press Any Key"; do{}while (!kbhit()); getch(); cout <<...
6
by: Johan Svedberg | last post by:
Hi! I read somewhere that it is impossible to write a program in ANSI-C which only reads one char from the keyboard without having to press Enter (i.e. -questions). Is this true? -- Johan...
5
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number...
0
by: neeraj | last post by:
Hi Everybody I have one problem in my asp.net web application. The problem is that I check the date validation in code behind; if user not gives the valid data and press save button then I fire...
9
by: Susan Rice | last post by:
I'm running a simple win32 console application and I want to impliment a "Press any key to continue", so I print that prompt, and then what's the easiest way to impliment reading any key? Do I use...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
1
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hello, I have a Default.aspx page with several controls in a Master Page. When pressing on a Button control Page_Load event is fired on the Default.aspx page and after that the Page_Load event...
3
by: win | last post by:
How to get the keycode press in a web form Vincent
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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,...

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.