hi all
this is my first post here. i have a small question and though i believe its a very simple one, however i cudnt figure it out until now.

i have written a vb 6 code to get data from rs232 port using mscomm control. i am getting the data from the device and its working fine. however i dont know how to stop getting the data. i mean i want a command button which when clicked will stop data collection. rite now what i m doing is i m stopping the entire code when i want to stop data collection.
any help/suggestions would be highly appreciated.
thanks.

thanks for ur reply. well i tried that.. but it says that it cant be closed until it is open
my code snippet is as follows..

Private Sub cmdStopCollection_Click()
   ' MSComm1.PortOpen = False
End Sub
 
Private Sub Form_Load()
 
   MSComm1.CommPort = 1
   MSComm1.Settings = "9600,N,8,1"
   MSComm1.InputLen = 0
   MSComm1.PortOpen = True
        
End Sub
 
Private Sub Timer1_Timer()
    txtDisplay.Text = txtDisplay.Text & MSComm1.Input & vbCrLf
End Sub

also i wud like to save the data i get from the rs232 into a file and also plot it as the data arrives to the port. any idea how i can do it or whether i can do it?
any help is appreciated.
thanks.

If you're getting a message saying that the port is closed then you're probably trying to close it twice and the error happens the second time.

Before closing check that it's actually open.

If MSComm1.PortOpen = True Then MSComm1.PortOpen = False

<<snip>>

Edited 6 Years Ago by Nick Evan: removed plug

Comments
spammy hijacker
This article has been dead for over six months. Start a new discussion instead.