Rules | Recent posts | topic RSS | Search | Register  | Log in

Serial Port In VB6

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Author Message
whassan



Joined: 25 Aug 2008
Posts: 1


Post25 Aug 2008 11:45   Serial Port In VB6

I have a (weight Bridge measure machine) for Weight the big Car . it have a serial port .

.We enter data through serial port in vb code but it gives in text box unclear letters and numbers.
#%y;< YW
this is code I used:

Private Sub Form_Load()
With MSComm1
.CommPort = 1
.Handshaking = comRTSXOnXOff
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
.EOFEnable = True
.InputMode = comInputModeText
.InputLen = 0
End With
end sub
Private Sub MSComm1_OnComm()

Dim Buffer As String
If MSComm1.CommEvent = 2 Then
Buffer = Buffer & MSComm1.Input & Chr(11)


Buffer = StrConv(MSComm1.Input, vbUnicode)


Me.Text1 = Buffer

end if


end sub
I tried all the solution but it did not give a result.


Please if someone have a solution help me to solve it.
Back to top
Moof



Joined: 21 Nov 2003
Posts: 154
Helped: 6
Location: Argentina


Post25 Aug 2008 13:38   Re: Serial Port In VB6

It could be because the data you are receiving is not ascii.

If that is the problem you can use Asc() to convert your data.


Here is an example

http://msdn.microsoft.com/en-us/library/zew1e4wc(VS.71).aspx
Back to top
Darth Maul



Joined: 19 Jul 2007
Posts: 18
Helped: 2
Location: Yogyakarta, Indonesia


Post29 Aug 2008 7:57   Serial Port In VB6

that Buffer variable should be declared as variant. whenever you send or receive data thorugh MSComm component, pass the data from/to a variant variable. the variant variable was assigned from/to other variable, be it a string (if you send or receive text data) or a byte array (if you send or receive raw binary data). cmiiw.
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap