Keyboard keys with visual basic

tmack

Member
I have been able to get a program running sending rs232 to a 08m and make leds go on and off. My next project Id like to do is to use my arrow keys on my keyboard to send out the rs232 data to make my robot go forward,backward left and right. Is therea way to do this with VB6? Thanks for any help.
 

Grant Fleming

Senior Member
Hi tmac,

Congratulations on the LED flashing (I have done the same with Liberty BASIC) but you have left all the guys hanging at your first thread on the same subject! They have offered help but have no reply from you on your progress.

Cheers,
Grant
 

hippy

Technical Support
Staff member
Sending direction commands is really no different to sending any other data, but you will likely have to tweak some VB code settings so you can catch the cursor key presses rather tha have Windows grab them. For VB6 I think this involves setting KeyPreview to true then watching KeyUp and KeyDown events. Get it working with normal printable keys first, then add cursor key handling afterwards.

Getting familiar with Google, Alta-Vista etc for hunting down VB solutions is something worth practicing because this forum can only really deal with specific PICAXE interface problems not generalised programming issues. People will help when they can but providing VB solutions is often quite complex, people don't have the time to do that, code can run to many pages, and explanations can take ages to write.

Now's also probably time to think about two other aspects of serial communications; connectivity and blocking.

What happens to your robot when you've sent it off in a direction and you lose communications ? Either because the cable gets pulled out, you accidentally minimise the control form, a system modal Windows message pops-up which stops your cursor keys having any effect, or worse still your VB6 program crashes and disconnects.

Tied into this is the blocking nature of SerIn. What happens while the robot is waiting for some data, and what happens if it is never received ? If you've set your robot to go forward, it's going to to that until told otherwise or falls off the edge of the world.

Chasing down a robot is probably good exercise, but if you replace your serial cable with a wireless interface and take to flying a plane instead, that's a more interesting situation to consider as it heads off over the horizon :)
 
Top