VB6 Error with serial communication

Status
Not open for further replies.
Hi,

Where exactly in the code did the error occur? (If you run it in debug mode, it should show you where the error happens.)
 
I build my own ericgibbs
hi.
You may have missed out a piece of code.

It should be like this, make sure you have all the 'components' on the form

Option Explicit

Private Sub cmdSend_Click()
Dim PinNumber As Long
Dim PinState As Long

' Get Pin Number
PinNumber = cboPinNumber.ListIndex

' Get Pin State
If optState(0).Value = True Then
PinState = 0
Else
PinState = 1
End If

' Send Out Data
MSComm1.Output = Chr$(255) & Chr$(PinNumber) & Chr$(PinState)

End Sub

Private Sub Form_Load()
Dim Pins As Long

' Add the pin numbers 0 to 15 to cboPinNumber
For Pins = 0 To 15
cboPinNumber.AddItem CStr(Pins)
Next Pins

' Default to Pin 0 being selected
cboPinNumber.ListIndex = 0

' Default to optState(0) being selected
optState(0).Value = True

' Use COM1
MSComm1.CommPort = 1

' 2400 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "2400,N,8,1"

' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = False

' Open the port
MSComm1.PortOpen = True

End Sub


Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
 

Attachments

  • 000esp01.gif
    3.8 KB · Views: 217
Thank you mdanh2002 and ericgibbs for the help. I downloaded the whole project instead to have no problem. I got it now working with no problem. I think I just missed something on my own made form. Thank you again
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…