I am new to visual basic 6 and I would like to write a code that can detect if serial port com1 is connected then the application will automatically close.
Thanks and appreciated your help!
I am new to visual basic 6 and I would like to write a code that can detect if serial port com1 is connected then the application will automatically close.
Thanks and appreciated your help!
First of all, like it's already said in the comments, you surely mean VB6 and not VBA.
Without any code it's difficult to give you a good answer. But I will try..
There is a MSComm Control in VB6 which is useful for serial communication. You can check the property 'PortOpen'
MSComm1.CommPort = 1
If MSComm1.PortOpen = False Then
Unload Me
End If
For further information check this question:
Problems opening and closing the mscomm port in vb6 when interfacing microcontroller
and see this documentation:
https://msdn.microsoft.com/en-us/library/aa259393(v=vs.60).aspx