Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

need simple VB code help

Status
Not open for further replies.

smcbob

Computer
Feb 24, 2005
3
I have VB 6.0 I haven't programmed in 10 years
I know this is not hard, but I just am having an awful time.
All I need to do is send the following out the rs232 (com 1)
scrlck scrlck uparrow esc

can someone send me source code on how to do this?

I feel stupid, but I just can't make it work.

thanks
 
Replies continue below

Recommended for you

For better help, this should be posted in the Visual Basic forum on this site or in the appropriate forum on Tek-Tips

TTFN
 
The easy way to access the serial port is with the MSComm control. There is some sample code in VB Help.

However as far as I know there are no standard ASCII codes for scrlck or uparrow

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

UK steam enthusiasts:
 
Have you looked at VB's SendKeys function? You can send {SCROLLLOCK}, {ESC} and {UP}.

Have fun.
 
As far as I know SendKeys will only simulate keypresses to the currently active window and not to a serial port.

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

UK steam enthusiasts:
 
o.k.
I have had such bad luck with VB that I actually went back to QBASIC.

here is the code I an using.

10 OPEN "COM1:9600,N,8,1,CS,DS,RS" FOR RANDOM AS #1
20 PRINT #1, CHR$(176) + CHR$(176) + CHR$(214) + CHR$(27)
30 END

chr$(176) is num lock ( using this instead of scroll lock)
chr$(214) is the up arrow
chr$(27) is the esc key

my problem now is that the keypress is not being released
so instead of the pc recieving numlock numlock up arrow esc
its recieving numlock-uparrow-esc.
(much like crtl-alt-del)
but it is not releasing the keypress.
also I am getting a chr$(13) (enter key press) without asking for one.
How do I get it to release the keypress?
I would greatly appreciate some direction on this.
 
It's been a long time since I use QB in earnest, but try:
PRINT #1, CHR$(176);CHR$(176);CHR$(214);CHR$(27);

The semicolon should send each character separately, and suppress the final (implied) <CR>

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

UK steam enthusiasts:
 
Thanks for the help.
the semicolon did get rid of the extra <cr>, but the keys still remain in the down state.
is there a chr$ value to release a key press?
or a command to reset the keyboard bios?

Who would have thought it was so hard to send four keystrokes out the rs232?
 
{SCROLLLOCK} is a toggle, isn't it?
Send it twice, it should be back where it started.
Send it too quick, it may get "debounced", with all but the first ignored.


Jay Maechtlen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor