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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial port communication

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP
Hi guys,

i want to get data from a station that link to a pc through a serial port.i'm thinking of writing a visual basic program to communicate to the station( using MScomm) and install the program on the pc.I want everytime data was entered through serial port, the data will be written to a text file in the PC

I'm really new to this and dont know what should i do. does somebody has sample codes ? am i'm doing the right thing . is there anyway to save data from the serial port to a text file?

thanks and regards
Nor
 
Hi
For reading serial port and write data to a file use following code


Code:
dim i as integer
Private Sub MSComm1_OnComm()
    Select Case MSComm1.CommEvent
        Case comEvReceive
            Dim Buffer As Variant
            Buffer = MSComm1.Input

            Open App.Path & "data_log.dat" For Random As #1
                i=i+1
                Put #1, i, Buffer
            Close #1
End Sub


 
Thanks for the valuable code,

But we did'nt specify where the filed is stored. can we staraight away put data into oracle database?

thanks and regards
 
You can put the data straight into oracle if you want. Buffer is variable storing the data coming from the port. so you can do what ever you want with that variable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top