Click to See Complete Forum and Search --> : gwbasic to VB


cporter
October 17th, 2001, 02:37 PM
I am very new to VB and now have a project I am working on that has me scratching my head. This is some code I have from gwBasic and it works but I want to put it in VB to make a gui interface. The following code runs circuts that open and close in a switch. I want to know if someone can help me put this into VB.


10 OPEN "COM1:19200,N,B,1,DS,CS" as #1
20 CLS:print"PRESS KEY"
30 for X=32 to 62 step 2
40 print #1,CHR$(X);
50 next X
60 for X=33 to 63 step 2
70 K$=INKEY$:IF K$="" THE 70
80 print"RELAY";(X+1)/2
90 print #1,CHR$(X);
100 next X
110 GOTO 20

d.paulson
October 17th, 2001, 06:05 PM
Here is my attempt. I have never used the mscomm control nor any com port programming with basic.

project with 1 command button, 1 textbox with multiline set to true, mscomm control.


Option Explicit
Dim x As Integer

Private Sub Command1_Click()
Text1 = ""
For x = 33 To 63 Step 2
Text1 = Text1 & "RELAY " & (x + 1) / 2 & vbCrLf
MSComm1.Output = Chr$(x)
Next x


End Sub

Private Sub Form_Load()
Command1.Caption = "Press Key"
Text1 = ""
MSComm1.CommPort = 1
MSComm1.Settings = "19200,n,8,1"
MSComm1.PortOpen = True
For x = 32 To 62 Step 2
MSComm1.Output = Chr$(x)
Next x

End Sub




David Paulson

cporter
October 17th, 2001, 07:02 PM
I appreciate your attempt, i will apply it and let you know the outcome.