Serial Interface 
Author Message
 Serial Interface

In VB6 you can use MSCOMM activeX to communicate with a serial port. Check
MSDN online for the programmer's reference of MSCOMM.


Quote:
> Howdy
> I'm new to newsgroups, so hope I haven't gone to far <g>
> but we all gotta learn somewhere ;o))

> I've just purchased a serial interface kit, the software examples supplied
> are GWbasic (talk about old <g>)
> I'ld like to know how to communicate with the interface via VB6 any tips
or
> code snips would be greatly appreciated
> The suppliers don't support the software side  ;o(((
> Below is a clippin of the code supplied with the kit (GWBasic), the byte
> format used (prob standard)
> and an addy on the PC interface card
> http://www.*-*-*.com/ +2850
> Thanks in advance
> Steve

> 10 CLS : KEY OFF: DEFINT A-Z: SCREEN 2: WINDOW SCREEN (0, 0)-(639, 199)
> 20 LINE (0, 0)-(639, 199), , B: LOCATE 2, 10: PRINT "RS232 I/O Test
> Program";
> 30 LOCATE 18, 5: INPUT "How many Modules are Connected (1-8)"; N
> 40 IF N < 1 OR N > 8 THEN 30 ELSE LOCATE 4, 5: PRINT "Module in use:"; N
> 50 OPEN "com1:9600,N,8,1,CS0,DS0,BIN" AS #1: A = 16: N = N - 1
> 60 LOCATE 4, 32: PRINT "input lines: 8 7 6 5 4 3 2 1"; : LINE
(375,35)-(580,
> 110), , B
> 70 FOR B = 0 TO N: PRINT #1, CHR$(A * B); : I$ = INPUT$(1, #1): GOSUB 1000
> 80 LOCATE (6 + B), 5: PRINT "current 4 line status (module "; (B + 1);
"):";
> 90 LOCATE (6 + B), 49: PRINT S; T; U; V; W; X; Y; Z;
> 100 LOCATE 18, 5: PRINT "Press any key to change an output line...";
> 110 K$ = INKEY$: IF K$ <> "" THEN GOSUB 500
> 120 NEXT B: GOTO 70
> 500 GOSUB 750: LOCATE 18, 5: INPUT "Which Module to be addressed (1-8)";
B:B
> = B - 1
> 510 IF B < 0 OR B > N THEN 500
> 520 LOCATE 20, 5: INPUT "which Output line to change (1-8)"; P
> 530 IF P < 1 OR P > 8 THEN 520 ELSE P = P - 1
> 540 LOCATE 22, 5: INPUT "Turn it ON (1) or OFF (0)"; C
> 550 IF C <> 1 AND C <> 0 THEN 540 ELSE C = C * 8
> 560 PRINT #1, CHR$((A * B) + P + C + 128); : GOSUB 750: RETURN
> 750 Q$ = SPACE$(45): FOR J = 18 TO 22 STEP 2: LOCATE J, 5: PRINT Q$; :
NEXT
> J: RETURN
> 1000 S = 0: T = 0: U = 0: V = 0: W = 0: X = 0: Y = 0: Z = 0: I = ASC(I$)
> 1010 IF I > 127 THEN S = 1: I = I - 128
> 1020 IF I > 63 THEN T = 1: I = I - 64
> 1030 IF I > 31 THEN U = 1: I = I - 32
> 1040 IF I > 15 THEN V = 1: I = I - 16
> 1050 IF I > 7 THEN W = 1: I = I - 8
> 1060 IF I > 3 THEN X = 1: I = I - 4
> 1070 IF I > 1 THEN Y = 1: I = I - 2
> 1080 IF I = 1 THEN Z = 1
> 1090 RETURN



Mon, 26 May 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Apple LaserWriter Pro serial interface

2. Control of Serial Interface by VBA

3. detecting non-working serial interface

4. serial interfacing

5. Anyone ever serial interfaced with a radio scanner?

6. Serial Interface

7. Q: Topper Serial Interfaces

8. serial interface VB component needed

9. Data Transfer over Serial Interface (V.24 / RS232)

10. problems with serial interfacing

11. Access to the serial interface, how can I read/write ASCII-Chars to COM1 ?

12. VBA interface to serial RS232 port

 

 
Powered by phpBB® Forum Software