Welcome to Dream.In.Code
Become a VB Expert!

Join 150,052 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,710 people online right now. Registration is fast and FREE... Join Now!




serial port programming

 
Reply to this topicStart new topic

serial port programming, serial data into access data base using VB 6.0

apuamy
24 Feb, 2008 - 04:00 AM
Post #1

New D.I.C Head
*

Joined: 24 Feb, 2008
Posts: 10

i want to get data coming from serial com port into an MS access data base.i am using VB 6.0 as front end and MS Access as back end.Can anybody help me.

This post has been edited by apuamy: 24 Feb, 2008 - 04:20 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Serial Port Programming
24 Feb, 2008 - 09:06 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks smile.gif

Just a small nudge, theres a control in VB6 that makes this much simpler than you would think, you're going to want to research the MSComm Control. This control will give you all the functionality you need for serial port communication.

Happy Coding! smile.gif
User is offlineProfile CardPM
+Quote Post

EMMADDAI
RE: Serial Port Programming
25 Feb, 2008 - 12:15 PM
Post #3

New D.I.C Head
*

Joined: 15 Nov, 2006
Posts: 7


My Contributions
could you please add what u've bn able to do. so that we try taking it up from there? thanks
User is offlineProfile CardPM
+Quote Post

realwish
RE: Serial Port Programming
26 Feb, 2008 - 08:49 PM
Post #4

New D.I.C Head
Group Icon

Joined: 29 Jan, 2008
Posts: 44


Dream Kudos: 25
My Contributions
the same i am still finding
User is offlineProfile CardPM
+Quote Post

LookNAO
RE: Serial Port Programming
27 Feb, 2008 - 10:22 AM
Post #5

D.I.C Head
**

Joined: 28 Dec, 2007
Posts: 66



Thanked: 1 times
My Contributions
Load the MSComm control.

Now depending on what you are hooking up to it, you need to know the following:
Baud rate
parity
data bit
stop bit

It will look something like : 9600, n, 8, 1

When you load the MSComm control, it does not work "out of the box".

set the following:

MSComm1.RThreshold = 1
MSComm1.SThreshold = 1

Depending on the handshaking:
MSComm1.DTREnable = False


Good luck



User is offlineProfile CardPM
+Quote Post

apuamy
RE: Serial Port Programming
26 Mar, 2008 - 10:56 AM
Post #6

New D.I.C Head
*

Joined: 24 Feb, 2008
Posts: 10

QUOTE(LookNAO @ 27 Feb, 2008 - 11:22 AM) *

Load the MSComm control.

Now depending on what you are hooking up to it, you need to know the following:
Baud rate
parity
data bit
stop bit

It will look something like : 9600, n, 8, 1

When you load the MSComm control, it does not work "out of the box".

set the following:

MSComm1.RThreshold = 1
MSComm1.SThreshold = 1

Depending on the handshaking:
MSComm1.DTREnable = False


Good luck


Thanks for the input
i am using baud rate, parity,databit and stop bit as 110,e,7,2.
no hand shaking
i am getting data in a text box, and can able to send out from a text box.
But now i have to send and store from a data base.
for sending i think this will work
x = Data1.Recordset.Fields("TTW Command")
MSComm2.Output = x

but for receiving data in a data base i am lost
I can still receive data line by line in a text box, but how can i store the same, serially in a data base under a field.
How this will affect
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
In my case both r 0.
my project involves connecting a computer with a RADAR for initiating certain command and getting results for its fault diagnostic.
User is offlineProfile CardPM
+Quote Post

apuamy
RE: Serial Port Programming
27 Mar, 2008 - 10:29 AM
Post #7

New D.I.C Head
*

Joined: 24 Feb, 2008
Posts: 10

Hi there,
i am sending th entire codes of the form down below
Dim strInput As String
Dim ser As Long



Private Sub Command1_Click()
ser = 1

Text1.Enabled = False
Text5.Enabled = False

MSComm1.Output = Text2.Text
Text1.Enabled = True
Text5.Enabled = True
Text2.Text = ""


End Sub

Private Sub Command2_Click()

End Sub

Private Sub Form_Load()


MSComm1.PortOpen = True
With Text1
'set the properties for the displaying textbox
.BackColor = vbCyan
.Locked = True
.Text = ""
End With 'Text1
With Text2
'set the properties for the 'send' textbox
.TabIndex = 0
.Text = ""
End With 'Text2
With Command1
'set the properties for the 'send' command button
.Caption = "&Send"
.Default = True
.TabIndex = 1
End With 'Command1

End Sub

Private Sub Form_Resize()
Dim sngWidth As Single, sngHeight As Single
Dim sngDisplayHeight As Single
Dim sngTxtWidth As Single
Dim sngCmdWidth As Single, sngCmdHeight As Single
'calculate the inner size of the form
sngWidth = ScaleWidth
sngHeight = ScaleHeight
With Command1
'resize and reposition the command button
sngCmdHeight = .Height
sngCmdWidth = .Width
sngDisplayHeight = sngHeight - sngCmdHeight
sngTxtWidth = sngWidth - sngCmdWidth
.Move sngTxtWidth, sngDisplayHeight, sngCmdWidth, sngCmdHeight
End With 'Command1
'resize and reposition the label
Text1.Move 0, 0, sngWidth, sngDisplayHeight
'resize and reposition the textbox
Text2.Move 0, sngDisplayHeight, sngTxtWidth, sngCmdHeight

End Sub

Private Sub Timer1_Timer()

If (MSComm1.InBufferCount > 0) Then

strInput = MSComm1.Input
Text1.Text = Text1.Text + strInput
Text5.Text = Text5.Text + strInput

End If


'storing input data in a data base
Data2.RecordSource = "SELECT * FROM rxmsg WHERE SER=" & ser
Data2.Refresh
Data2.Recordset.Edit
Data2.Recordset.Fields("RXMSG") = Text5.Text
Data2.UpdateRecord
ser = ser + 1
Text5.Text = ""
End Sub

After loading the form, i hit on command button to send data.After this the device replies back and can be seen in text box1.now i am simultaneously put the same receive data in textbox 5. After that i am trying to transfer the data to a data base. After a line is received , i erase the textbox 5 and again go for the next line.
The error i am getting
1st on loading form- object doesnt support the property or method
2nd- Run time error '3021' No current record

I have a doubt the codes written in the timer1 in red colour
has to be written there or else where. On running the program cannot be stopped normally, but by task manager.
data base 2 concerned table has two field i.e SER and RXMSG. ser is being incremented to go to the particular record and fill.
Thanks for helping me.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:17PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month