Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2006, 04:31 PM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to cammarata123
Default Vb.net 2002 Keys Queston

Hi I am only 13 and have been doing vb.net for only a few months but so I dont know anything amazingly complex. I have a question about keys. I am working on a game where when you press the right key your character moves right, left and your character moves left etc...

I do know how to make other classes and other forms and to call to them so far all I got was

if system.windows.forms.keys.right() then

end if

but I dont know how to make it so an event is fired if its pressed.
Please anwser


Nick Cammarata
 
Old November 16th, 2006, 02:25 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Hi Nick.

The events that are fired already (and so is what you should use) are keydown and keypress. Within whichever of those 2 best suits your needs, process for which key is involved, and take the action you have in mind if it is the key you're after.

Within these events, you can prevent continuation of the standard handling of the key. In other words, if it is your key, handle it and prevent further normal processing, else ignore it, and allow normal processing.

Does that help?

Brian

[edited part follows]
By the way, the way to fire an event—if you in fact must—is with RaiseEvent.
 
Old November 16th, 2006, 06:13 PM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to cammarata123
Default

Thank you so much for replying, well I found the anwser I was looking for and it was

if e.keycode = system.windows.forms.keys.a then
messagebox.show("It Worked")
end if

Nick Cammarata





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net 2002 Std and Crystal 9 Prof HELP reyboy Crystal Reports 0 April 21st, 2005 05:32 AM
Can't get VB.NET 2002 to get updates mmcdonal VB.NET 1 October 28th, 2004 11:13 PM
vb.net 2002 OR vb.net 2003 metalaaron VB.NET 2002/2003 Basics 0 August 5th, 2003 10:00 AM
vb.net 2002 - vb.net 2003 book metalaaron Wrox Book Feedback 0 August 2nd, 2003 10:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.