Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 109,540 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 1,213 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Visual basic serial communication

 
Reply to this topicStart new topic

Visual basic serial communication

rupeshtsawant
post 8 Aug, 2008 - 04:23 AM
Post #1


New D.I.C Head

*
Joined: 3 Aug, 2008
Posts: 3


Like following are the fields in my access table

SrNo. 8spaces

Date – 15 spaces

Time of Test- 10 spaces

Set Pressure-10 spaces

Achieved Pressure-9 spaces

Leak value-11 spaces

Result-10 spaces

The equipment which i connect to serial port it gives me data in above size and i want to store that data in the access table. and again to display on Vb front end.
format

I have already used Mid function but it is not working fine. here is the my code

it means now i get combined data of 2/ 3 fields in a single field of access table

but I want that data in different fields .

i used MSComm control in project
and i set following properties Inputlen=73 RThreshold = 73

if i set these properties to 1 then please suggest me the code

CODE


Private Sub Form_Load()
stranswer = InputBox("Enter the Database Name to store the records", "Database Name")

Set filesystemobject = CreateObject("scripting.filesystemobject")
        'On Error GoTo copy
        'MkDir "D:\data_base_copy"
'copy:
        filesystemobject.copyfile "D:\data_base_copy\Processflow.mdb", "D:\data_base_copy\" + stranswer + ".mdb"

Set con = New ADODB.Connection
con.ConnectionString = "Provider = Microsoft.jet.oledb.4.0;Data Source = D:\data_base_copy\" + stranswer + ".mdb"
con.Open

Set rs = New ADODB.Recordset
rs.Open "select * from graphdb", con, adOpenDynamic, adLockOptimistic


With MSComm1
        .CommPort = 1
        .Handshaking = 0 - comNone
        .RThreshold = 73
        .RTSEnable = True
        .PortOpen = True
        .Settings = "19200,n,8,1"
        .SThreshold = 1
        .InputMode = 0 - comInputModeText
        .InputLen = 73
End With
flag = -1
cnt = 0
z = 0
'Open "c:\ram.txt" For Output As #1
Timer1.Enabled = False
End Sub

Private Sub MSComm1_OnComm()
error:

Select Case MSComm1.CommEvent
        Case comEventBreak
        Case comEventCDTO
        Case comEventCTSTO
        Case comEventDSRTO
        Case comEventFrame
        Case comEventOverrun
        Case comEventRxOver
        Case comEventRxParity
        Case comEventTxFull
        Case comEventDCB
        Case comEvCD
        Case comEvCTS
        Case comEvDSR
        Case comEvRing
        Case comEvReceive
        Case comEvSend
        Case comEvEOF
        
End Select

On Error GoTo error
rsin = MSComm1.Input
'If rsin = 74 Then

rs.AddNew

'If flag = -1 Then
'    res1 = StrComp(rs, "A")
'    If res1 = 0 Then
'    flag = 0
'    Exit Sub
'    End If
'Else

r1 = Mid(rsin, 1, 8)
r2 = Mid(rsin, 9, 23)
r3 = Mid(rsin, 24, 33)
r4 = Mid(rsin, 34, 43)
r5 = Mid(rsin, 44, 52)
r6 = Mid(rsin, 53, 63)
r7 = Mid(rsin, 64, 73)

rs.Fields(0) = z
rs.Fields(1) = r1
rs.Fields(2) = r2
rs.Fields(3) = r3
rs.Fields(4) = r4
rs.Fields(5) = r5
rs.Fields(6) = r6
rs.Fields(7) = r7
z = z + 1
rs.Update
'rs.AddNew
'rs.Requery
'rs.Close


End Sub


User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 09:52PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month