Author |
Message |
Alan Summerli #1 / 2
|
 Serial Interface
Wow... and not even well written GW-BASIC at that. What you want to use is called the MSComm control. There are several good examples on the MSDN CD that comes with VB6. You should be able to find other good examples on the Internet by searching for matches to "MSComm". Hope this helps and good luck. Quote:
> Howdy > 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 software side ;o((( > Attached is the byte format used (prob standard) > Below is a clippin of the code supplied with the kit (GWBasic) > 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 > [Image]
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Thomas Lu #2 / 2
|
 Serial Interface
You can use the MSCOMM.OCX that comes with VB to do the job. I would recommend getting a good book on it like the Visual Basic Programmers Guide to Serial Communications by Richard Grier. You can find it at www.amazon.com There should also be a sample serial communications program that demonstrates the MSComm control in the sample programs that come with Visual Basic. The MSComm control also has a fairly good help file that shows how to use it. For serial I/O tools, tutorials and free utilities visit www.taltech.com On Sun, 03 Dec 2000 23:09:51 GMT, "Steve Thurston" Quote:
>Howdy >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 software side ;o((( >Attached is the byte format used (prob standard) >Below is a clippin of the code supplied with the kit (GWBasic) >Addy on the PC interface card >http://www.altronics.com.au/cat.asp?cat=11&grp=424&id=K+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
|
Thu, 29 May 2003 10:35:19 GMT |
|
|
|