Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

save data to file direct using mscomm1 using port 1

Status
Not open for further replies.

wannabe1234

Programmer
May 1, 2007
3
GB
Hi guys,

i wrote a program here to collect data and save the data to file where i can open the file later.

here the program i've wrote.

Private Sub Form_Load()
MSComm1.PortOpen = True
End Sub

Private Sub Timer1_Timer()
Dim InputString
If MSComm1.InBufferCount = 256 Then
Close #1
Open "c:\test.cli" For Output As #1
InputString = MSComm1.Input
For x = 1 To 256
A$ = Mid$(InputString, x, 1)
Print #1, Asc(A$)
Next x
End If
Close #1

End Sub

It require only time and mscomm to the form.
The result expected should store the data collect from port 1 and save it in file "test.cli" in c directory. No error occured during run. The only problem is that there is no file "test.cli" on c directory. please help. Thanks
 
1. Where did you intialise the timer?
2. Where did you set the timers interval?
3. Why are you using a timer?

[gray]Experience is something you don't get until just after you need it.[/gray]
 
this program opens the serial port, checks the input buffer every 5 seconds and if the buffer contains 256 bytes, reads in the string, breaking in into 256 separate bytes and string these as 'test.cli' in c directory. the only components needed are mscomm and timer which can be set the interval to 5000 at the timer properties. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top