| | |
Programming keyboard keys in vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 6
Reputation:
Solved Threads: 0
Hi all
I am working on application which displays text on the screen as one word of a line at a time. Now words are changing at a set speed of 240ms using ( system.threading.thread.sleep).But i want change words on the screen using left and right arrow key so that if the user does not like the preset speed then the speed can be adjusted using left and right arrow key. At the moment i dont have much idea about how to add keys functionality to my application.
Any help would be much appreciated.
Thanks
I am working on application which displays text on the screen as one word of a line at a time. Now words are changing at a set speed of 240ms using ( system.threading.thread.sleep).But i want change words on the screen using left and right arrow key so that if the user does not like the preset speed then the speed can be adjusted using left and right arrow key. At the moment i dont have much idea about how to add keys functionality to my application.
Any help would be much appreciated.
Thanks
In the forms properties set KeyPreview to True and then use the Key subs that the form supplies
AND/OR You can check which key was pressed using To handle the Left key press
VB.NET Syntax (Toggle Plain Text)
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown End Sub
VB.NET Syntax (Toggle Plain Text)
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp End Sub
VB.NET Syntax (Toggle Plain Text)
If e.KeyCode = Keys.Left Then End If
•
•
Join Date: Nov 2008
Posts: 6
Reputation:
Solved Threads: 0
Thanks for your reply...code is working beautifully
I am using space key to initialize a thread which starts flashing text on the screen. Now the problem is that if i press the same key again then same thread gets started again and t.abort or t.suspend is not working either.
My idea is pause the thread if the same key is pressed again...like an on off button..
If e.KeyCode = Keys.Space Then
Dim value As Boolean = False
Control.CheckForIllegalCrossThreadCalls = value
Dim t As Thread
t = New Thread(AddressOf rsvp)
If t.IsAlive = False Then
t.Start()
Else : t.Abort()
End If
End If
I am using space key to initialize a thread which starts flashing text on the screen. Now the problem is that if i press the same key again then same thread gets started again and t.abort or t.suspend is not working either.
My idea is pause the thread if the same key is pressed again...like an on off button..
If e.KeyCode = Keys.Space Then
Dim value As Boolean = False
Control.CheckForIllegalCrossThreadCalls = value
Dim t As Thread
t = New Thread(AddressOf rsvp)
If t.IsAlive = False Then
t.Start()
Else : t.Abort()
End If
End If
![]() |
Similar Threads
- pop ups are back (Viruses, Spyware and other Nasties)
- This is a wierd one! (Windows NT / 2000 / XP)
- Zone Alarm Security Alerts. (Viruses, Spyware and other Nasties)
- special keys as inputs (Game Development)
Other Threads in the VB.NET Forum
- Previous Thread: create a .cab file
- Next Thread: Help Regarding CrystalReports
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google hardcopy html images input insert intel internet mobile monitor net networking objects open output panel passingparameters pdf picturebox picturebox1 port position print printing problem save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





